睡觉前显示无模式 wxDialog
我有一个 wxPython 应用程序,我希望对话框显示五秒钟。因为我想做的非常简单,所以我创建了以下代码:
dlg = WaitDialog(self, "Wait 5 seconds...")
dlg.Show(True)
time.sleep(5)
dlg.close()
问题是 dlg 仅在等待 5 秒后才显示。有没有办法告诉wxPython在到达sleep语句之前更新?
感谢您的帮助
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该使用 wx.Timer 来代替。使用 time.sleep 将阻塞 wxPython 主循环。请参阅文档 http://www.wxpython.org/docs/api/ wx.Timer-class.html 或本教程:http://www.blog.pythonlibrary.org/2009/08/25/wxpython-using-wx-timers/
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/