What's the simplest cross-platform way to pop up graphical dialogs in Python?

后端 未结 10 2150
一生所求
一生所求 2020-12-13 04:15

I want the simplest possible way to pop up simple dialogs in Python scripts. Ideally, the solution would:

  • Work on Windows, OS X, Gnome, KDE
  • Look like
10条回答
  •  囚心锁ツ
    2020-12-13 04:47

    The PyMsgBox module does almost exactly this. It uses the built-in tkinter module for its 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.

    Native look-and-feel message boxes will be available in a future version.

    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/

提交回复
热议问题