How to bring subprocess to the foreground?

D

dudeja.rajat

Hi,

I've a batch file that I open with the subprocess .Popen() . When this
batch file is run I want to bring it to the foreground.

Please suggest how can I do this?


Regards,
Rajat
 
D

Diez B. Roggisch

Hi,

I've a batch file that I open with the subprocess .Popen() . When this
batch file is run I want to bring it to the foreground.

Please suggest how can I do this?

You can't. You can capture the stdout using the pipe-arguments, and in
your main-process, read that and write it to the main process' stdout.

Diez
 
D

dudeja.rajat

You can't. You can capture the stdout using the pipe-arguments, and in your
main-process, read that and write it to the main process' stdout.

Diez

Hi Diez,

Thanks for the information.
That's valuable information.

I though of displayin an information message on the screen through
tkMessageBox while the subprocess is running, I did it using:

try:
testing = subprocess.Popen([batchFilePath], \
shell = True)

retCode = testing.wait()
tkMessageBox._show("Test Harness execution", \
icon = 'info', \
message="Testing %s in progress..." % libName)
except:
tkMessageBox._show("Error", \
type='ok', icon='error', \
message="Error executing %s Test
Harness" % libName)
return None
else:
print retCode


But the message is never displayed. Please suggest if there is
something wrong with this code
 
P

Paul Boddie

I though of displayin an information message on the screen through
tkMessageBox while the subprocess is running, I did it using:

try:
testing = subprocess.Popen([batchFilePath], \
shell = True)

retCode = testing.wait()

Note that you wait for the process to finish here...
tkMessageBox._show("Test Harness execution", \
icon = 'info', \
message="Testing %s in progress..." % libName)

....and that you show a message about the process running *after*
waiting until it isn't running any more.
except:
tkMessageBox._show("Error", \
type='ok', icon='error', \
message="Error executing %s Test
Harness" % libName)
return None
else:
print retCode

But the message is never displayed. Please suggest if there is
something wrong with this code

I think you should first show your message, *then* wait for the
process to finish.

Paul
 
D

dudeja.rajat

I though of displayin an information message on the screen through
tkMessageBox while the subprocess is running, I did it using:

try:
testing = subprocess.Popen([batchFilePath], \
shell = True)

retCode = testing.wait()

Note that you wait for the process to finish here...
tkMessageBox._show("Test Harness execution", \
icon = 'info', \
message="Testing %s in progress..." % libName)

...and that you show a message about the process running *after*
waiting until it isn't running any more.
except:
tkMessageBox._show("Error", \
type='ok', icon='error', \
message="Error executing %s Test
Harness" % libName)
return None
else:
print retCode

But the message is never displayed. Please suggest if there is
something wrong with this code

I think you should first show your message, *then* wait for the
process to finish.

Paul

Such a silly mistake I'm committing.
Thanks a ton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,079
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top