Introduction to the Tkinter askokcancel() function The askokcancel() function shows a confirmation dialog that has two buttons: OK and Cancel. answer = askokcancel(title, message, **options)Code language: Python (python) If you click the OK button, the function returns True. However, if you click the Cancel button, the function returns False. Tkinter askokcancel() example The following program shows a Delete All button. If you clickContinue Reading

Introduction to tkinter.messagebox module When developing a Tkinter application, you often want to notify users about the events that occurred. For example, when users click the save button, you want to notify them that the record has been saved successfully. If an error occurred, for example, the database server is notContinue Reading

You’ll convert the temperature converter application to a new one that uses object-oriented programming approach: First, define a class called TemperatureConverter. The class has one static method that converts a temperature from Fahrenheit to Celsius: import tkinter as tk from tkinter import ttk from tkinter.messagebox import showerror class TemperatureConverter: @staticmethod def fahrenheit_to_celsius(f): return (f – 32)Continue Reading

In the previous tutorial, you’ve learned how to subclass the Tkinter.Tk class. However, a Tkinter application should have only one Tk instance. Therefore, it’s common to inherit from the ttk.Frame class and use the subclass in the root window. To inherit the ttk.Frame class, you use the following syntax: class MainFrame(ttk.Frame): passCode language: Python (python) Since a Frame needs aContinue Reading

Defining a Tkinter object-oriented window The following simple program creates a root window and displays it on the screen: import tkinter as tk root = tk.Tk() root.mainloop()Code language: Python (python) When the program is getting more complex, you can use an object-oriented programming approach to make the code more organized. The following program achievesContinue Reading

Changing the cursor for the root window The root window has only two cursors: The Normal cursor has the value of “” while the busy cursor has the value of “watch”. The following program shows how to change the cursor of the root window from normal to busy: import tkinter as tk rootContinue Reading