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.
pip install PyMsgBoxVerified import paths — ran on the pinned version, not inferred.
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.
On Debian/Ubuntu-based systems: `sudo apt-get install python3-tk`. On Arch Linux: `sudo pacman -S tk`.
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.
Handle `None` as a possible return value for user cancellation or dialog closure via the 'X' button.
Always refer to the PyPI page for the most up-to-date version information when installing via `pip`.
On Debian/Ubuntu-based systems, install Tkinter using `sudo apt-get install python3-tk`. For other operating systems or Python distributions, ensure Tkinter is included with your Python installation or installed via your system's package manager.
Ensure Tkinter is installed for your Python version. On Linux (Debian/Ubuntu), use `sudo apt-get install python3-tk`. If you are in a virtual environment, make sure Tkinter is accessible within that environment.
Try updating `pip`, `setuptools`, and `wheel` (`python -m pip install --upgrade pip setuptools wheel`). If on Linux, ensure development headers for Python and Tkinter are installed (e.g., `sudo apt-get install python3-dev python3-tk` for Python 3 on Debian/Ubuntu). Sometimes, a broken `apt` installation can also cause this, which can be fixed by running `sudo apt --fix-broken install` followed by `sudo apt-get update`.
Upgrade `pymsgbox` to the latest version (`pip install --upgrade pymsgbox`), as this issue might have been resolved in newer releases. Also, ensure your Python and Tkinter installations are up-to-date. In earlier versions, clicking 'X' might return `None` (like 'Cancel'), but if no response is registered at all, an upgrade is recommended.