The example of how to use threads in the documentation that i am following
is here.
LongRunningTasks - wxPyWiki
What I am after is how to put the WorkerThread into it's own file and use
from worker_thread import WorkerThread in the MainFrame file.
i have been successful so far, but where i get hung up is what to do with
the EVT_RESULT_ID .
If i have both in the same file, it works, but if i declare EVT_RESULT_ID in
both files, the thread runs, but does not update the GUI.
here is the line:
# Define notification event for thread completion
EVT_RESULT_ID = wx.NewId()
what that says is: "give me a unique ID to use".
so if you have that same line in two different modules, you'll get two
different IDs -- which is NOT what you want.
I'd put that line in the thread module, then get it from the thread
module in your other module:
EVT_RESULT_ID - thread_module.EVT_RESULT_ID
then they will be the same.
but yo may not need that ID --
that code defines a new event:
def EVT_RESULT(win, func):
....
so what you really need is that: EVT_RESULT. So you can change this line:
# Set up event handler for any worker thread results
EVT_RESULT(self,self.OnResult)
to:
# Set up event handler for any worker thread results
thread_module.EVT_RESULT(self,self.OnResult)
and that should do it (if the event definitions are in teh thread
module, which they should be.
NOTE: you can make all this easier by using wx.CallAfter instead.
HTH,
-chris
···
On Tue, Apr 3, 2012 at 8:41 AM, Shawn Bright <shawn@skrite.net> wrote:
I appreciate any help here. Still very much a beginner to wxpython.
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (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