{"id":5699,"library":"pymsgbox","title":"PyMsgBox","description":"PyMsgBox is a simple, cross-platform, pure Python module designed to display JavaScript-like message boxes. It provides `alert()`, `confirm()`, `prompt()`, and `password()` functions. Currently at version 2.0.1, the library leverages Python's built-in Tkinter module for its graphical user interface, offering a consistent experience across different operating systems. While it aims for a pure Python implementation, underlying OS GUI toolkit installations (like `python-tk` on Linux) may sometimes be required for Tkinter to function correctly. The project is actively maintained, with releases primarily driven by bug fixes and minor enhancements.","status":"active","version":"2.0.1","language":"en","source_language":"en","source_url":"https://github.com/asweigart/PyMsgBox","tags":["GUI","messagebox","dialog","cross-platform","tkinter","popup"],"install":[{"cmd":"pip install PyMsgBox","lang":"bash","label":"Install PyMsgBox"}],"dependencies":[{"reason":"Used for GUI rendering. Included with Python, but may require OS-level installation (e.g., 'python-tk' on Linux).","package":"tkinter","optional":false}],"imports":[{"symbol":"alert","correct":"import pymsgbox\npymsgbox.alert('Hello!')"},{"symbol":"confirm","correct":"import pymsgbox\nresponse = pymsgbox.confirm('Proceed?')"},{"symbol":"prompt","correct":"import pymsgbox\nname = pymsgbox.prompt('Your Name:')"},{"symbol":"password","correct":"import pymsgbox\npw = pymsgbox.password('Password:')"}],"quickstart":{"code":"import pymsgbox\n\n# Display a simple alert box\npymsgbox.alert('This is an alert message!', 'My Application Alert')\n\n# Display a confirmation box\nresponse_confirm = pymsgbox.confirm('Do you want to continue?', 'Confirmation', ['Yes', 'No'])\nprint(f'Confirmation response: {response_confirm}')\n\n# Display a prompt for text input\nuser_input = pymsgbox.prompt('Please enter your name:', 'Name Input', defaultValue='Guest')\nprint(f'User entered: {user_input}')\n\n# Display a password input box\nuser_password = pymsgbox.password('Enter your secret password:', 'Secure Input', mask='*')\nprint(f'Password entered (masked): {user_password if user_password else \"None\"}')\n\n# Example with timeout\ntimeout_response = pymsgbox.alert('This alert will close in 2 seconds.', timeout=2000)\nprint(f'Timeout alert response: {timeout_response}')","lang":"python","description":"This quickstart demonstrates the four main functions of PyMsgBox: `alert`, `confirm`, `prompt`, and `password`. It also shows how to use custom buttons and a timeout parameter."},"warnings":[{"fix":"On Debian/Ubuntu-based systems: `sudo apt-get install python3-tk`. On Arch Linux: `sudo pacman -S tk`.","message":"PyMsgBox relies on Python's built-in Tkinter module for its GUI. On some Linux distributions, Tkinter may require an additional system package (e.g., `python-tk` or `tk`) to be installed, even though Python itself is installed.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that using `pymsgbox.native` might result in inconsistent UI/feature behavior across platforms. Test thoroughly or stick to the default `pymsgbox` functions if full customizability is critical.","message":"The `pymsgbox.native` module provides limited support for displaying OS-native message boxes. However, these native dialogs may not support all arguments (e.g., custom buttons for `alert()` or `confirm()` on Windows) and will default back to Tkinter-based dialogs if certain features are unsupported on the platform.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Handle `None` as a possible return value for user cancellation or dialog closure via the 'X' button.","message":"When using `prompt()` or `password()` functions, clicking the red 'X' (close) button on the dialog typically behaves the same as clicking the 'Cancel' button, returning `None`. The dialog will block program execution until closed by the user.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the PyPI page for the most up-to-date version information when installing via `pip`.","message":"There is a discrepancy between the latest PyPI release version (2.0.1) and the `__version__` string found in the `__init__.py` of the GitHub master branch (1.0.9). This may cause confusion for developers who check the source code directly for the latest version or expected features.","severity":"gotcha","affected_versions":"2.0.1 (PyPI) vs. 1.0.9 (GitHub master branch)"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}