

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 −
- Related Questions & Answers
- Different ways to print exception messages in Java
- Tkinter Programming in Python
- How to print exception messages in android?
- How do I disable log messages from the Requests Python module?
- Create multiple buttons with "different" command function in Tkinter
- destroy() method in Tkinter - Python
- Python - geometry method in Tkinter
- after method in Python Tkinter
- Collapsible Pane in Tkinter Python
- askopenfile() function in Python Tkinter
- Binding function in Python Tkinter
- Progressbar widget in Python Tkinter
- asksaveasfile() function in Python Tkinter
- Mouse Position in Python Tkinter
- How to write custom Python Exceptions with Error Codes and Error Messages?