By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,332 Members | 1,202 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,332 IT Pros & Developers. It's quick & easy.

C# and Python

P: n/a
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
Share this Question
Share on Google+
8 Replies

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.