473,503 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoiding DOS Window...

Hello NG,

I don't know if this is the right place to post this question, but
noting that it is os-related probably someone will have some nice idea.
I have built an application using Python+wxPython, and I have compiled it
into an exe file using py2exe. In my app, I use a call:

self.process = os.spawnl(os.P_NOWAIT, MyCommand)

where MyCommand is a call to an external exe file. When I run my
application (without the DOS window), a new DOS window is created for every
call to os.spawnl. This is something I would like to avoid because I don't
need to have 50 DOS windows opened on my PC. Moreover, I need to keep a
reference to self.process, because I woule like to be able to kill the
process when the user decides to kill it. In order to kill it, I use a
command like:

if self.process is not None:
if wx.Platform == '__WXGTK__':
try:
status = os.kill(self.process, 9)
except:
pass
else:
try:
win32api.TerminateProcess(self.process,0)
except:
pass
status = 0

self.process = None

I thought I could use os.popen* things, but it seems to me that they do not
return something that could be killed using os.kill() or
win32api.TerminateProcess().
Am I missing something about the os things? Does anyone have a better
solution?

Thanks to you all.

Andrea.
------------------------------------------------------------------------------------------------------------------------------------------
Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/
Jul 18 '05 #1
2 1721
Andrea,

Take a look at Win32 extensions CreateProcess method.
You can control the window location/size or run
minimized.
win32process.CreateProcess(execute_target,
commandLine,
processAttributes,
threadAttributes,
bInheritHandles,
dwCreationFlags,
newEnvironment,
currentDirectory,
STARTUPINFO)

Larry Bates

an***********@agip.it wrote:
Hello NG,

I don't know if this is the right place to post this question, but
noting that it is os-related probably someone will have some nice idea.
I have built an application using Python+wxPython, and I have compiled it
into an exe file using py2exe. In my app, I use a call:

self.process = os.spawnl(os.P_NOWAIT, MyCommand)

where MyCommand is a call to an external exe file. When I run my
application (without the DOS window), a new DOS window is created for every
call to os.spawnl. This is something I would like to avoid because I don't
need to have 50 DOS windows opened on my PC. Moreover, I need to keep a
reference to self.process, because I woule like to be able to kill the
process when the user decides to kill it. In order to kill it, I use a
command like:

if self.process is not None:
if wx.Platform == '__WXGTK__':
try:
status = os.kill(self.process, 9)
except:
pass
else:
try:
win32api.TerminateProcess(self.process,0)
except:
pass
status = 0

self.process = None

I thought I could use os.popen* things, but it seems to me that they do not
return something that could be killed using os.kill() or
win32api.TerminateProcess().
Am I missing something about the os things? Does anyone have a better
solution?

Thanks to you all.

Andrea.
------------------------------------------------------------------------------------------------------------------------------------------
Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/

Jul 18 '05 #2
Launching a subprocess without a console window

http://aspn.activestate.com/ASPN/Coo.../Recipe/409002

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4323
by: Generale Cluster | last post by:
hello, I've made a template which has the layout I want, but there is an undesired white space between the left elements and the right column. How can I remove it? Thank you Bye!! Here's the...
3
1367
by: John Baker | last post by:
Hi: When Access opens, the user gets a glimpse of table lists and other ugliness before the startup screen appears (set in the startup process). Is there some way that i can avoid this and even...
1
2617
by: Pedro Graca | last post by:
Well ... I've been using Windows for a long time before I switched to Linux. I'm very used to type CTRL-ALT-DEL everytime I'm leaving my computer or arriving to it. It's hapenned _twice_ (in the...
2
3001
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
1
3256
by: Cindy H | last post by:
Hi I used the code below to automatically open a pdf file when the user clicks on a menu option. It works great on local machine, but when I uploaded it to hosting site and then tried it, I...
1
2031
by: milti | last post by:
Hi All!! Is there any way, I can avoid the Print Dialog from appearing multiple times? Let me be more clear. I've say three files. file1.html, file2.html and file3.html. there's a button...
4
23256
by: jodleren | last post by:
Hi all I have a file I open in a smaller window, like this: <a href="#" onclick="window.open.... but it also causes the main window to jump to the top. What have people done to avoid that?...
3
2549
by: guest | last post by:
I have a problem, I have Javascript that opens a popup. I want to avoide the user from closing the parent window first. I dont want to use showDialog, I want to use window.open() only.. Is there any...
3
1311
by: anithaa | last post by:
hi, i am creating a windows application in visual studio 2005. currently i have designed many forms.the problem i have is; in my first form i have a button which should redirect me to the...
0
7086
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...
1
6991
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...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
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,...
1
5014
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...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.