473,699 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2592

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.ProcessI nfo 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.cawro te:
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.c omwrote:
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.c omwrote:
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.cawro te:
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.