Reputation: 303
I have a wxPython application where I want a dialog to be displayed for five seconds. Since I wanted to do it really simple, I've created the following code:
dlg = WaitDialog(self, "Wait 5 seconds...")
dlg.Show(True)
time.sleep(5)
dlg.close()
The problem is that dlg is displayed only after waiting those 5 seconds. Is there any way to tell wxPython to update before reaching the sleep sentence?
Thanks for your help
Upvotes: 0
Views: 197
Reputation: 33071
You should use a wx.Timer instead. Using time.sleep will block wxPython main loop. See the docs http://www.wxpython.org/docs/api/wx.Timer-class.html or this tutorial: http://www.blog.pythonlibrary.org/2009/08/25/wxpython-using-wx-timers/
Upvotes: 2