473,915 Members | 7,703 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 2603

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
9883
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,...
0
11359
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11069
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,...
0
9734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8102
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
7259
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
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
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.