Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Python Tkinter - Create Button Widget
Next article icon

Tkinter provides amessagebox class which can be used to show variety of messages so that user can respond according to those messages. Messages like confirmation message, error message, warning message etc.
In order to use this class one must import this class as shown below: 
 

# import all the functions and constants of this class.from tkinter.messagebox import *


  
Syntax and uses of different functions of this class - 
 

# Ask if operation should proceed; # returntrue if the answer isok.# Ask a question.# Ask if operation should be retried;# returntrue if the answer isyes.# Ask a question; returntrue# if the answer isyes.# Ask a question; returntrue# if the answer isyes,None ifcancelled.# Show an error message.# Show an info message.# Show a warning message.


  
Program to demonstrate various messages:
 

Python3
# importing messagebox classfromtkinter.messageboximport*# Showing various messagesprint(askokcancel("askokcancel","Ok or Cancel"))print(askquestion("askquestion","Question?"))print(askretrycancel("askretrycancel","Retry or Cancel"))print(askyesno("askyesno","Yes or No"))print(askyesnocancel("askyesnocancel","Yes or No or Cancel"))print(showerror("showerror","Error"))print(showinfo("showinfo","Information"))print(showwarning("showwarning","Warning"))# print statement is used so that we can# print the returned value by the function

Output: 
 


 


 


 


 


 


 


 


Note: Note that in above program we don not have to importTkinter module onlymessagebox molude/class is sufficient because definitions of these functions is inmessagebox class.
 


Improve
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp