- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Different messages in Tkinter - Python
Tkinter is the GUI module of python. It uses various message display options which are in response to the user actions or change in state of a running program. The message box class is used to display variety of messages like confirmation message, error message, warning message etc.
Example-1
The below example shows display of a message with the background colour, font size and colour etc customizable.
import tkinter as tk main = tk.Tk() key = "the key to success is to focus on goals and not on obstacles" message = tk.Message(main, text = key) message.config(bg='white', font=('times', 32, 'italic')) message.pack() tk.mainloop()
Running the above code gives us the following image −
Example-2
In the below examples we see the display of many standard actions like showing information or showing an error etc. There are different functions of the messagebox class that are used to show various message categories.
The Question Box
This is achieved by using askquestion() function.
Example
from tkinter.messagebox import * print(askquestion("Question", "Proceed to next Step?"))
Running the above code gives us the following result −
The Retry Box
This is achieved by using askretrycancel() function.
from tkinter.messagebox import * print(askretrycancel("Retry", "Try Again?"))
Running the above code gives us the following result −
The Error Box
This is achieved by using showerror() function.
from tkinter.messagebox import * print(showerror("Error", "Error in checkout"))
Running the above code gives us the following result −
The Warning Box
This is achieved by using askretrycancel() function.
from tkinter.messagebox import * print(showwarning("Warning", "This may result in delay !"))
Running the above code gives us the following result −