Naishadh shroff. wrote:
Hi ,
I see this link. It is interesting. but still i am not sure how to solve my problem. I am trying. Here i am posting some code. Just look at it.
#wxpython on run button eventdef OnRun(self,event):
print "Before the script start"
#This thread class start the back ground script which is generating jpg for panel
RunScript().start()
print "After the script start"
#Sleep time thread initialization and script is costly so it takes some time
time.sleep(30)
print "After the 30 script start"
#Loop that displaying the images
for i in range(0, 9):
print "loop start",i
self.imageFile1="./results/r10001t"+str(i)+".asc.jpg"
self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (580,620))
self.obj.Refresh()
time.sleep(5)
print "loop done",iNow every thing is working fine. But the my wxpython is unresponsive now. N wiered thing is when i run only script or only loop. The wxpython is working perfectly.
CONFUSED... big time
Thanks,
Naish
All event handlers run in the same thread. Therefore you cannot process other events (such as clicking on a button, closing the window, typing a key, etc.) until you finish processing this one. That's why your app becomes unresponsive while control is inside this event handler. So you need to fork another thread for your long-running process. Also you should not create a new widget (wx.StaticBitmap) in an event handler. I'm not sure what will happen when you try this, but it won't be good.