WxPython:如何在固定时间内显示任何消息窗口,让它自动消失
我正在使用python和Wxpython为GUI作品设计一个软件。我想在一段固定的时间内向用户显示一条消息,然后让它自动消失。 我想不出怎么做。 Plz帮助。。。WxPython:如何在固定时间内显示任何消息窗口,让它自动消失,python,wxpython,python-2.7,Python,Wxpython,Python 2.7,我正在使用python和Wxpython为GUI作品设计一个软件。我想在一段固定的时间内向用户显示一条消息,然后让它自动消失。 我想不出怎么做。 Plz帮助。。。 提前感谢..类似的方法应该会奏效: import threading msgbox = wx.MessageBox('Hey user, there is something I want to tell you!', 'Alert', wx.ICON_EXCLAMATION | wx
提前感谢..类似的方法应该会奏效:
import threading
msgbox = wx.MessageBox('Hey user, there is something I want to tell you!',
'Alert', wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
threading.Timer(10.0, msgbox.EndModal).start()
我现在没有机会测试它,但我认为这是一个重要的总体想法。类似的东西应该会起作用:
import threading
msgbox = wx.MessageBox('Hey user, there is something I want to tell you!',
'Alert', wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
threading.Timer(10.0, msgbox.EndModal).start()
我现在没有机会测试它,但我认为这是最重要的总体想法。您可以使用wx.BusyInfo或wx.lib.agw.pybusyinfo。下面的示例显示一条非模态消息,持续3秒钟。要摆脱messagebox对话框,只需将其名称ref设置为None
import time
import wx
import wx.lib.agw.pybusyinfo as PBI
def showmsg():
app = wx.App(redirect=False)
msg = 'this is a test'
title = 'Message!'
d = PBI.PyBusyInfo(msg, title=title)
return d
if __name__ == '__main__':
d = showmsg()
time.sleep(3)
d = None
祝你好运,
Mike您可以使用wx.BusyInfo或wx.lib.agw.pybusyinfo。下面的示例显示一条非模态消息,持续3秒钟。要摆脱messagebox对话框,只需将其名称ref设置为None
import time
import wx
import wx.lib.agw.pybusyinfo as PBI
def showmsg():
app = wx.App(redirect=False)
msg = 'this is a test'
title = 'Message!'
d = PBI.PyBusyInfo(msg, title=title)
return d
if __name__ == '__main__':
d = showmsg()
time.sleep(3)
d = None
祝你好运,
Mike它不起作用,你需要先创建wx.App。它不起作用,你需要先创建wx.App。