预览

image.png

代码

  1. import ctypes
  2. import time
  3. # 自动关闭窗口
  4. def auto_close_dialog(title, close_until_seconds):
  5. time.sleep(close_until_seconds)
  6. wd = ctypes.windll.user32.FindWindowA(0, title)
  7. ctypes.windll.user32.SendMessageA(wd, 0x0010, 0, 0)
  8. return
  9. # 提示框
  10. def show_dialog(text, title, close_until_seconds):
  11. # 取消自动关闭 删除前两行代码
  12. # t = threading.Thread(target=auto_close_dialog, args=(title, close_until_seconds))
  13. # t.start()
  14. MB_OK = 0x0
  15. MB_OKCXL = 0x01
  16. MB_YESNOCXL = 0x03
  17. MB_YESNO = 0x04
  18. MB_HELP = 0x4000
  19. ICON_EXLAIM = 0x30
  20. ICON_INFO = 0x40
  21. ICON_STOP = 0x10
  22. ctypes.windll.user32.MessageBoxA(0, text, title, MB_YESNO | ICON_STOP)
  23. if __name__ == '__main__':
  24. show_dialog('这是内容'.encode('gbk'), '这是标题'.encode('gbk'), 0.5)