PyMsgBox

2.0.1 · active · verified Thu Apr 09

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.

Warnings

Install

Imports

Quickstart

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}')

view raw JSON →