预览
代码
import ctypes
import time
# 自动关闭窗口
def auto_close_dialog(title, close_until_seconds):
time.sleep(close_until_seconds)
wd = ctypes.windll.user32.FindWindowA(0, title)
ctypes.windll.user32.SendMessageA(wd, 0x0010, 0, 0)
return
# 提示框
def show_dialog(text, title, close_until_seconds):
# 取消自动关闭 删除前两行代码
# t = threading.Thread(target=auto_close_dialog, args=(title, close_until_seconds))
# t.start()
MB_OK = 0x0
MB_OKCXL = 0x01
MB_YESNOCXL = 0x03
MB_YESNO = 0x04
MB_HELP = 0x4000
ICON_EXLAIM = 0x30
ICON_INFO = 0x40
ICON_STOP = 0x10
ctypes.windll.user32.MessageBoxA(0, text, title, MB_YESNO | ICON_STOP)
if __name__ == '__main__':
show_dialog('这是内容'.encode('gbk'), '这是标题'.encode('gbk'), 0.5)