Sending a command via threading

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.

Yes, have looked at that page. Guess will need to dig into it even more.
wxCallAfter, tried, just must not be passing the right params.
Not finding much documentation on the wxCallAfter at all.

I've gotten this far, not going to quit now. My App is working great except
for this issue. The task takes a bit because have to filter out a bunch of
html and get the values.

Think I have got some kind of threading working. Results were spit out, but
Gui still unresponsive during the process, so must not have gotten it right.

Maybe going to have to drop the insistance that the app keep command line
entry available. The examples I'm finding don't seem to be using anything like
that, can't figure out how to mix the os.popen with the treading.

I'll run thru the LongRunningTasks again.

Thanks, Dave

David wrote:

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.

Yes, have looked at that page. Guess will need to dig into it even more.
wxCallAfter, tried, just must not be passing the right params. Not finding much documentation on the wxCallAfter at all.

_wxCallAfterId = None

def wxCallAfter(callable, *args, **kw):
     """
     Call the specified function after the current and pending event
     handlers have been completed. This is also good for making GUI
     method calls from non-GUI threads.
     """
     app = wxGetApp()
     assert app, 'No wxApp created yet'

     global _wxCallAfterId
     if _wxCallAfterId is None:
         _wxCallAfterId = wxNewEventType()
         app.Connect(-1, -1, _wxCallAfterId,
               lambda event: event.callable(*event.args, **event.kw) )
     evt = wxPyEvent()
     evt.SetEventType(_wxCallAfterId)
     evt.callable = callable
     evt.args = args
     evt.kw = kw
     wxPostEvent(app, evt)

I've gotten this far, not going to quit now. My App is working great except
for this issue. The task takes a bit because have to filter out a bunch of
html and get the values.

Think I have got some kind of threading working. Results were spit out, but
Gui still unresponsive during the process, so must not have gotten it right.

The key is never stop and wait for something in event handlers. If you have something that could take more than a "noticable amount of time" (a few tens or hundreds of a millisecond) then you should find some way to not have to wait for it. Either use a worker thread, or break up the task into smaller chunks and then handle each chunk individually in a EVT_IDLE handler or a timer, or something similar.

ยทยทยท

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