|Passing multiple values to a Thread||Daniel Fontaine||9/8/11 2:20 PM|
Like a lot of people, I seem to be stuck on threading.
I have an app which retrieves multiple forms of user input
(wxTextCtrl, wxChoice, etc.)
This data is then crunched by a function. Being a newbie GUI
programmer, I didn't realize this would block the application's GUI
when a time-consuming function was called.
I did some research, and found out I probably needed threading. After
working through some examples, I tried to apply threading to my
Unfortunately, I wasn't able to figure out how to pass the variables
containing user input to the new, data-crunching thread. I don't know
if I'm looking at it the wrong way, or if I completely missed
Could someone try to specify and specific terms when/where I pass
multiple variables (can also be another data-type) containing the user
input to the new thread?
|Re: Passing multiple values to a Thread||Mike Driscoll||9/8/11 2:25 PM|
I think this is probably the best all-encompassing article on wxPython and threads: http://wiki.wxpython.org/LongRunningTasks and this is a simple one: http://www.blog.pythonlibrary.org/2010/05/22/wxpython-and-threads/
When I start a new thread, I have always passed the information needed to it when I create the thread. Then I start the thread. If you need to actually send it additional data, then you'll probably need to read the Python documentation on the Threading module. Once you've passed the info and the thread finishes crunching the data, it can then tell the GUI to update using wx.CallAfter or wx.PostEvent.
|Re: [wxPython-users] Passing multiple values to a Thread||Chris Weisiger||9/8/11 2:35 PM|
On Thu, Sep 8, 2011 at 2:20 PM, Daniel Fontaine
Here's a simple script that demonstrates creating a standard Python
def crunch(a, b, c, resultQueue):
resultQueue = Queue.Queue()
Since you don't want to have your main thread block while the
wx.CallAfter(processResult, (a * b) + c)
where processResult is another function, accepting one argument in this case.
Hope that helps.
|Re: [wxPython-users] Passing multiple values to a Thread||Robin Dunn||9/9/11 12:42 AM|
Remember that anything that interacts with the GUI needs to be done in