Python EasyGUI – Message Box

Message Box : It is used to display a window having a message or information in EasyGUI, it can be used where there is a need to display some message or some important information, it contains message and a “Ok” button which when pressed closes the message, below is how the message box looks like

EasyGUI is a module for very simple, very easy GUI programming in Python. EasyGUI is different from other GUI generators in that EasyGUI is NOT event-driven. Instead, all GUI interactions are invoked by simple function calls. Unlike other complicated GUI’s EasyGUI is the simplest GUI till now. EasyGUI depends on the Tkinter module.

In order to do this we will use msgbox method

Syntax : msgbox(message, title, ok_button_text)

Argument : It takes 3 arguments, first string i.e message/information to be displayed, second string i.e title of the window and third is string i.e display text of the OK button



Return : It returns the text of the OK button

Example :
In this we will create a message box having a message and will set the display text of the OK button, below is the implementation

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing easygui module
from easygui import *
  
# message / information to be displayed on the screen
message = "This is a Mesage Box in EasyGUI"
  
# title of the window
title = "GfG - EasyGUI"
  
# text of the Ok button
ok_btn_txt = "Continue"
  
# creating a message box
output = msgbox(message, title, ok_btn_txt)
  
# printing the output
print("User pressed  : " + output)

chevron_right


Output :

User pressed  : Continue

Another Example
In this we will create a window having message and title but without changing the text of the ok button

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing easygui module
from easygui import *
  
# message / information to be displayed on the screen
message = "This is a Mesage Box in EasyGUI (GeeksforGeeks)"
  
# title of the window
title = "GfG - EasyGUI"
  
# creating a message box
output = msgbox(message, title)
  
# printing the output
print("User pressed  : " + output)

chevron_right


Output :

User pressed  : OK

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.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.