How can I create a simple message box in Python?

后端 未结 17 1355
心在旅途
心在旅途 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:37

    The PyMsgBox module does exactly this. It has message box functions that follow the naming conventions of JavaScript: alert(), confirm(), prompt() and password() (which is prompt() but uses * when you type). These function calls block until the user clicks an OK/Cancel button. It's a cross-platform, pure Python module with no dependencies.

    Install with: pip install PyMsgBox

    Sample usage:

    import pymsgbox
    pymsgbox.alert('This is an alert!', 'Title')
    response = pymsgbox.prompt('What is your name?')
    

    Full documentation at http://pymsgbox.readthedocs.org/en/latest/

提交回复
热议问题