Registry / web-framework / pymsgbox

pymsgbox

JSON →
library2.0.1pypypi✓ verified 24d ago

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 PyMsgBox
INSTALL
IMPORT
SIG · PYMSGBOX
P
pymsgbox
web-frameworkpythonv2.0.1
Install
1.5s avg
Import
84ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.092s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.076s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

alert
import pymsgbox pymsgbox.alert('Hello!')
confirm
import pymsgbox response = pymsgbox.confirm('Proceed?')
prompt
import pymsgbox name = pymsgbox.prompt('Your Name:')
password
import pymsgbox pw = pymsgbox.password('Password:')

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.

import pymsgbox # Display a simple alert box pymsgbox.alert('This is an alert message!', 'My Application Alert') # Display a confirmation box response_confirm = pymsgbox.confirm('Do you want to continue?', 'Confirmation', ['Yes', 'No']) print(f'Confirmation response: {response_confirm}') # Display a prompt for text input user_input = pymsgbox.prompt('Please enter your name:', 'Name Input', defaultValue='Guest') print(f'User entered: {user_input}') # Display a password input box user_password = pymsgbox.password('Enter your secret password:', 'Secure Input', mask='*') print(f'Password entered (masked): {user_password if user_password else "None"}') # Example with timeout timeout_response = pymsgbox.alert('This alert will close in 2 seconds.', timeout=2000) print(f'Timeout alert response: {timeout_response}')
Debug
Known issues
gotchaPyMsgBox 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.
fix
On Debian/Ubuntu-based systems: `sudo apt-get install python3-tk`. On Arch Linux: `sudo pacman -S tk`.
affects: All versions
gotchaThe `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.
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.
affects: All versions
gotchaWhen 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.
fix
Handle `None` as a possible return value for user cancellation or dialog closure via the 'X' button.
affects: All versions
gotchaThere 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.
fix
Always refer to the PyPI page for the most up-to-date version information when installing via `pip`.
affects: 2.0.1 (PyPI) vs. 1.0.9 (GitHub master branch)
Errors
Common errors & fixes
ModuleNotFoundError: No module named '_tkinter'
PyMsgBox relies on Python's built-in Tkinter module for its graphical interface, and this error indicates that the Tkinter module or its underlying C implementation (_tkinter) is missing or not correctly installed in your Python environment. This is common on Linux distributions where Tkinter is not always installed by default with Python.
fix
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.
AssertionError: Tkinter is required for pymsgbox
This error occurs when `pymsgbox` attempts to use Tkinter, but the library detects that Tkinter is not available or properly imported. This often points to the same underlying issue as `ModuleNotFoundError: No module named '_tkinter'`, where the necessary Tkinter components are not present.
fix
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.
Failed building wheel for pymsgbox
This error typically arises during the `pip install PyMsgBox` process and indicates a problem compiling or packaging the library, often due to missing build dependencies or issues with the local Python environment.
fix
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`.
Message box red 'X' button does not work / PyMsgBox window does not close
In some versions or environments, the default behavior of the Tkinter window manager (which `pymsgbox` uses) might not correctly register clicks on the window's close button ('X'), preventing the message box from closing and potentially halting the script.
fix
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.
Upgrade
Version history
2.0.1latest on PyPI · released Sep 9, 2025
Audit
Dependencies
tkinterrequiredUsed for GUI rendering. Included with Python, but may require OS-level installation (e.g., 'python-tk' on Linux).
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
pymsgbox — pip install pymsgbox · libregistry