PyMsgBox is simple, cross-platform, purely implemented in Python for message boxes as JavaScript has. It uses Python’s built-in Tkinter module for its GUI.
Installation
This module does not built-in Python. To install it type the below command in the terminal.
pip install PyMsgBox
There are four functions in PyMsgBox, which follow JavaScript’s message box naming conventions:
- alert()
- prompt()
- confirm()
- Timeout()
- password()
alert()
This method shows a message box with text and a single button. It returns the text of the button.
Syntax:
alert(text='', title='', button='OK')
Python3
import pymsgbox as a b = a.alert( "This is alreat" , 'Title' ) # OK whatever you type, it will return OK print (b) |
Output:
confirm()
This method displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.
Syntax:
confirm(text='', title='', buttons=['OK', 'Cancel'])
Python3
import pymsgbox as a a.confirm( 'This is text' , 'This is title' , ' ' ) |
Output:
prompt()
This method displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked.
Syntax:
prompt(text='', title='', defaultValue='')
Python3
import pymsgbox as a a.prompt( 'Text' , 'Title' , 'Default' ) |
Output:
password()
This method will show a masked character in place of every character typed.
Syntax:
password(text,title,masking-character)
Python3
import pymsgbox as a a.password( "Enter Password" , 'This is Title of your application' , ' ', ' - ') |
Output: