How can I create a simple message box in Python?

后端 未结 17 1372
心在旅途
心在旅途 2020-11-30 16:44

I\'m looking for the same effect as alert() in JavaScript.

I wrote a simple web-based interpreter this afternoon using Twisted.web. You basically submit

17条回答
  •  长情又很酷
    2020-11-30 17:30

    In Windows, you can use ctypes with user32 library:

    from ctypes import c_int, WINFUNCTYPE, windll
    from ctypes.wintypes import HWND, LPCSTR, UINT
    prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT)
    paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0)
    MessageBox = prototype(("MessageBoxA", windll.user32), paramflags)
    
    MessageBox()
    MessageBox(text="Spam, spam, spam")
    MessageBox(flags=2, text="foo bar")
    

提交回复
热议问题