Discussion:
[Python.NET] Issues with running a phyton script from c#
Mahi Haile
2009-08-16 04:05:05 UTC
Permalink
I am able to run a phyton script from C# using a code similar to:

p = new Process()
p.StartInfo.Filename = path/to/script
p.StartInfo.Arguments = string_with_arguments
p.StartInfo.CreateNoWindow = true
p.Start()


I am not interested in the script outcomes since the script just
starts a Tk app with its own Gui.

The problem/annoyance I am having is when the process starts, it does
so with a command window that points to python instalation location
(so something like C:\Python25\python.exe) and just hangs there until
I quit the Tk gui. Is there a way to get rid of this command window?
If I close the command window manually, the Tk app closes as well.

Thank you for your help,
Craig Farrow
2009-08-17 08:57:15 UTC
Permalink
For running stand-alone python scripts you can rename your .py file to
.pyw, which disables the console window when you run it. Does that
achieve the same result from your C# code?

Craig.
Post by Mahi Haile
p = new Process()
p.StartInfo.Filename = path/to/script
p.StartInfo.Arguments = string_with_arguments
p.StartInfo.CreateNoWindow = true
p.Start()
I am not interested in the script outcomes since the script just
starts a Tk app with its own Gui.
The problem/annoyance I am having is when the process starts, it does
so with a command window that points to python instalation location
(so something like C:\Python25\python.exe) and just hangs there until
I quit the Tk gui. Is there a way to get rid of this command window?
If I close the command window manually, the Tk app closes as well.
Thank you for your help,
------------------------------------------------------------------------
_________________________________________________
http://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________
Python.NET mailing list - ***@python.org
http://mail.pyt
Maksim Kozyarchuk
2009-08-17 11:38:44 UTC
Permalink
Launching the application using pythonw.exe instead of python should resolve this.



________________________________

From: pythondotnet-bounces+mkozyarchuk=***@python.org <pythondotnet-bounces+mkozyarchuk=***@python.org>
To: ***@python.org <***@python.org>
Sent: Sun Aug 16 00:05:05 2009
Subject: [Python.NET] Issues with running a phyton script from c#


I am able to run a phyton script from C# using a code similar to:

p = new Process()
p.StartInfo.Filename = path/to/script
p.StartInfo.Arguments = string_with_arguments
p.StartInfo.CreateNoWindow = true
p.Start()


I am not interested in the script outcomes since the script just
starts a Tk app with its own Gui.

The problem/annoyance I am having is when the process starts, it does
so with a command window that points to python instalation location
(so something like C:\Python25\python.exe) and just hangs there until
I quit the Tk gui. Is there a way to get rid of this command window?
If I close the command window manually, the Tk app closes as well.

Thank you for your help,
Mahi Haile
2009-08-17 14:20:39 UTC
Permalink
Thank you!Either renaming the script to a .pyw or launching the app with
pythonw.exe got rid of the problem. So, the block of code exactly the same
with a minor change as:

[option 1]
p = new Process()
p.StartInfo.Filename = path/to/script //Here use a .pyw instead of a .py
file
p.StartInfo.Arguments = string_with_arguments
p.StartInfo.CreateNoWindow = true
p.Start()

[option 2]
p = new Process()
p.StartInfo.Filename = path/to/pythonw.exe
p.StartInfo.Arguments = path/to/script + any_string_args //(delimited by
spaces as in the command line)
p.StartInfo.CreateNoWindow = true
p.Start()

Thanks again,

On Mon, Aug 17, 2009 at 7:38 AM, Maksim Kozyarchuk <
Post by Maksim Kozyarchuk
Launching the application using pythonw.exe instead of python should resolve this.
------------------------------
python.org>
*Sent*: Sun Aug 16 00:05:05 2009
*Subject*: [Python.NET] Issues with running a phyton script from c#
p = new Process()
p.StartInfo.Filename = path/to/script
p.StartInfo.Arguments = string_with_arguments
p.StartInfo.CreateNoWindow = true
p.Start()
I am not interested in the script outcomes since the script just
starts a Tk app with its own Gui.
The problem/annoyance I am having is when the process starts, it does
so with a command window that points to python instalation location
(so something like C:\Python25\python.exe) and just hangs there until
I quit the Tk gui. Is there a way to get rid of this command window?
If I close the command window manually, the Tk app closes as well.
Thank you for your help,
Loading...