lower, spawn an external program, raise window

Hi there,

I have a question. How to run an external program from wxPython app so
that before the external program starts it lowers the window and once
finished it raises the window?
I tried something like that:

def onDoExternal(self, evt):
   self.Lower()
   # run cmd
   th=threading.MyThread("sth", self, self.cmd)
   th.start()
   # wait till cmd finishes (5 sec is enough)
   time.sleep(5)
   # kill my thread softly (see Python Cookbook rec. 6.2
   # Terminating a Thread)
   # terminate here!
   th.join()

def cmd(self):
  # do something here
  # os.popen(...) could be here
  os.system("cmd")

MyTread's join method has a call to self.Raise(), (a window instance is
passed to the MyThread's constructor)

In the result window doesnt' lower. What do I do wrong?

Many thanks,
~Serge

···

+++++
This mail has been sent through the MPI for Demographic Research. Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.

Serge Boiko wrote:

Hi there,

I have a question. How to run an external program from wxPython app so
that before the external program starts it lowers the window and once
finished it raises the window?
I tried something like that:

def onDoExternal(self, evt):
   self.Lower()
   # run cmd
   th=threading.MyThread("sth", self, self.cmd)
   th.start()
   # wait till cmd finishes (5 sec is enough)
   time.sleep(5)
   # kill my thread softly (see Python Cookbook rec. 6.2
   # Terminating a Thread)
   # terminate here!
   th.join()

def cmd(self):
  # do something here
  # os.popen(...) could be here
  os.system("cmd")

MyTread's join method has a call to self.Raise(), (a window instance is
passed to the MyThread's constructor)

In the result window doesnt' lower. What do I do wrong?

You don't let control return to the MainLoop so it can update things like that. Instead you block waiting for the thread (so why have the thread in the first place?)

If you use wxExecute and wxProcess then you can get a notification when the process completes. See the demo for an example.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!