Sending a command via threading

Haven't found a clear enough example on how to do this yet, maybe someone
can point me in the correct direction or give me some.

Write now I click a button event and send the command to the main program.
Trying to keep the main program able to accept commands via stdin still, so
using the popen like Robin suggested.

def onMF8(self,event):
  self.frame.ScreenerDisp.SetValue("Please Wait filtering results...")
  result = os.popen("python /home/david/picker.py --screener test")
  while 1:
    line = result.read()
    if line == "":
      break
       self.frame.ScreenerDisp.WriteText(line)
    return

The results are perfect and prints to the TextCtrl. This particular process
(picker.py --screener test) is labor intensive and takes a minute to a couple
to complete (depending on the net connection).

I haven't been able to figure out how to start this off in it's own
thread via threading. The gui blanks out if leave the window and
can't do anything else. The program works fine on command line if doing
the --screener test and in another window you have it do something
else. Would like to get the gui doing the same thing. Any help?

Thanks,

Dave

David wrote:

I haven't been able to figure out how to start this off in it's own thread via threading. The gui blanks out if leave the window and
can't do anything else. The program works fine on command line if doing
the --screener test and in another window you have it do something
else. Would like to get the gui doing the same thing. Any help?

See http://wiki.wxpython.org/index.cgi/LongRunningTasks and other docs on the wiki.

There is also a little simpler way to communicate from the worker thread to your gui thread. Just use wxCallafter and it will invoke the method in the context of the gui thread passing the args you give it.

···

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

Have you check out this Wiki Page?

http://wiki.wxpython.org/index.cgi/LongRunningTasks

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov