如何在python中创建一个MessageBox (如示例中所示),并在几秒钟后从代码中关闭它?
m= win32gui.MessageBox(None,data, "SnapShot", 0x00000000L) #creating a messagebox with the message and OK button发布于 2017-04-16 17:50:05
使用Win32接口中的setTimer函数注册要在几毫秒后执行的函数;在注册的函数中,关闭对话框。例如,下面是在1秒后关闭对话框的代码:
from win32 import timer as w32timer
def close_messagebox(*args):
m.close()
w32timer.setTimer(1000, close_messagebox)(未测试的代码)
其他方法,如使用Python的sched模块或threading都不起作用,因为必须从主线程关闭对话框。Windows计时器的想法是让事件在事件循环中发生。
https://stackoverflow.com/questions/43435787
复制相似问题