Skip to content
Related Articles

Related Articles

Improve Article

PyMsgBox module in Python

  • Last Updated : 22 Jun, 2021

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:

 

pymsgbox confirm



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:



 

pymsgbox prompt

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:

 

pymsgbox password

 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up