avoid gui being blocked
Marcus Stojek
stojek at part-gmbh.de
Mon Mar 25 15:32:39 EST 2002
Hi,
let's say I have a Dialog (using wxPython) with a button.
This button starts a function thats takes some time to
return. During this time the GUI is not responding to
any action of the user. How can I keep the GUI alive?
I tried starting "go" in a thread, but the only way I can
check for the thread being finished is either
thread.join()
or:
while thread.isAlive():
pass
In both cases the GUI still doesn't respond. Is there something
like a thread-exit event I could use. And how?
This should be an all day problem, but I don't find a hint.
Thanks in advance,
Marcus
#-------------------------------------------------------------------
from wxPython.wx import *
import time
class Frame(wxFrame):
def __init__(self,parent):
ID_Button=wxNewId()
wxFrame.__init__(self,parent,-1,"title")
d=wxDialog(self,-1,"Dialog")
wxButton(d,ID_Button,"Do it",wxDefaultPosition,
wxDefaultSize)
EVT_BUTTON(d,ID_Button,self.go)
d.ShowModal()
def go(self,event):
time.sleep(10)
return 1
class Main(wxApp):
def OnInit(self):
frame=Frame(NULL)
return 1
app = Main(0)
app.MainLoop()
More information about the Python-list
mailing list