472,145 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

C# and Python

Hi,
I am a newcomer in Python. I am going to write a small Python
application that will run in windows xp. This application needs to
have GUI. Is it possible to make a C# application using visual studio
2005 that will call the python scripts? Let me explain more here:
My program will generate a text file of 100 - 100000 random integers,
and sort those using various sorting methods. Now I have written
separate sorting scripts in Python (quick sort, insertion sort etc.).
But I want to write the GUI and number generation program in C#.net.
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.

regards,
Subeen

Aug 21 '07 #1
8 2523

On 21 aug 2007, at 12.01, subeen wrote:
Hi,
I am a newcomer in Python. I am going to write a small Python
application that will run in windows xp. This application needs to
have GUI. Is it possible to make a C# application using visual studio
2005 that will call the python scripts? Let me explain more here:
My program will generate a text file of 100 - 100000 random integers,
and sort those using various sorting methods. Now I have written
separate sorting scripts in Python (quick sort, insertion sort etc.).
But I want to write the GUI and number generation program in C#.net.
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.

regards,
Subeen

--
http://mail.python.org/mailman/listinfo/python-list
If C# can call extension functions written in C, then it's possible.
See info on how to embed a Python interpreter in a custom C application.
-----------------------------------------------------
An astronomer to a colleague:
-I can't understsnad how you can go to the brothel as often as you
do. Not only is it a filthy habit, but it must cost a lot of money too.
-Thats no problem. I've got a big government grant for the study of
black holes.
Tommy Nordgren
to************@comhem.se

Aug 21 '07 #2
On Aug 21, 12:01 pm, subeen <tamim.shahr...@gmail.comwrote:
Hi,
I am a newcomer in Python. I am going to write a small Python
application that will run in windows xp. This application needs to
have GUI. Is it possible to make a C# application using visual studio
2005 that will call the python scripts? Let me explain more here:
My program will generate a text file of 100 - 100000 random integers,
and sort those using various sorting methods. Now I have written
separate sorting scripts in Python (quick sort, insertion sort etc.).
But I want to write the GUI and number generation program in C#.net.
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.
If you just want to capture the stdout of a script then you can use
the System.Process and System.ProcessInfo classes. An example is
here:

http://gflanagan.net/site/dotnet/vst...from_word.html

HTH

Gerard

Aug 21 '07 #3
subeen wrote:
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.
One way to do this:
In your C# app, have the mouse click event handler call python
interpreter "/path/to/python /path/to/quicksort.py". Make quicksort.py
write to a file the result. After the quicksort.py finishes, read the
file from your normal C# app.

Cheers.
Aug 21 '07 #4
Ant
On Aug 21, 11:01 am, subeen <tamim.shahr...@gmail.comwrote:
Hi,
....
But I want to write the GUI and number generation program in C#.net.
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.
Probably worth looking at IronPython, the Python implementation for
the .Net platform.

--
Ant...

http://antroy.blogspot.com/
Aug 21 '07 #5
From Eric CHAO [accidently sent to me]:

Maybe you could try IronPython. It's another implement in .NET
platform. Not 100% compatible but for sorting, that's ok. I think it's
a better way to use GUI that .NET provide.

And if you download VS 2005 SDK, there is many demo projects about
IronPython.

On 8/21/07, Bikal KC <ne***************@yahoo.cawrote:
subeen wrote:
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.
One way to do this:
In your C# app, have the mouse click event handler call python
interpreter "/path/to/python /path/to/quicksort.py". Make quicksort.py
write to a file the result. After the quicksort.py finishes, read the
file from your normal C# app.

Cheers.
--
http://mail.python.org/mailman/listinfo/python-list

Aug 21 '07 #6
On 8/21/07, Ant <an****@gmail.comwrote:
On Aug 21, 11:01 am, subeen <tamim.shahr...@gmail.comwrote:
Hi,
...
But I want to write the GUI and number generation program in C#.net.
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.

Probably worth looking at IronPython, the Python implementation for
the .Net platform.

--
Also Pythonnet (see the recent announce on this ML), which is a
..NET/CPython bridge and supports embedding CPython as well as calling
..NET code from CPython.
Aug 21 '07 #7
On Aug 21, 7:24 pm, "Chris Mellon" <arka...@gmail.comwrote:
On 8/21/07, Ant <ant...@gmail.comwrote:
On Aug 21, 11:01 am, subeen <tamim.shahr...@gmail.comwrote:
Hi,
...
But I want to write the GUI and number generation program in C#.net.
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.
Probably worth looking at IronPython, the Python implementation for
the .Net platform.
--

Also Pythonnet (see the recent announce on this ML), which is a
.NET/CPython bridge and supports embedding CPython as well as calling
.NET code from CPython.
Thanks everyone for your valuable suggestions. I shall let you know my
status.

Regards,
Subeen.

Aug 21 '07 #8
On Aug 21, 5:00 pm, Bikal KC <nepbabucxspamf...@yahoo.cawrote:
subeenwrote:
When the user clicks Quick Sort button, the quicksort.py will be
called and it will sort the numbers.

One way to do this:
In your C# app, have the mouse click event handler call python
interpreter "/path/to/python /path/to/quicksort.py". Make quicksort.py
write to a file the result. After the quicksort.py finishes, read the
file from your normal C# app.

Cheers.
Hi, what's the C# function to call python interpreter?

regards,
Subeen.

Aug 23 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.