Display a bar chart from matplotlib in Tkinter applications Matplotlib is a third-party library for creating professional visualizations in Python. Since Matplotlib is a third-party library, you need to install it before use. To install the matplotlib package, you can use the following pip command: pip install matplotlibCode language: Python (python) The following programContinue Reading

Introduction to the Tkinter validation Tkinter validation relies on the three options that you can use for any input widget such as Entry widget: validate The validate command can be one of the following string values: ‘focus’ Validate whenever the widget gets or loses focus ‘focusin’ Validate whenever the widget gets focus. ‘focusout’ ValidateContinue Reading

Introduction to Tkinter MVC As your application grows, its complexity also increases. To make the application more manageable, you can use the model-view-controller design pattern. The MVC design pattern allows you to divide the application into three main components: model, view, and controller. This structure helps you focus on theContinue Reading

This tutorial assumes that you know how to use the after() method and understand how threadings work in Python. Also, you should know how to switch between frames using the tkraise() method. In this tutorial, you’ll build a picture viewer that shows a random picture from unsplash.com using its API. If you make an HTTPContinue Reading

When to use Thread in Tkinter applications In a Tkinter application, the main loop should always start in the main thread. It’s responsible for handling events and updating the GUI. If you have a background operation that takes time, you should execute it in a separate thread. Otherwise, the application won’tContinue Reading

Introduction to Tkinter after() method All Tkinter widgets have the after() method with the following syntax: widget.after(delay, callback=None)Code language: Python (python) The after() method calls the callback function once after a delay milliseconds (ms) within Tkinter’s main loop. If you don’t provide the callback, the after() method behaves like the time.sleep() function. However, the after() method uses the millisecond instead of the second as the unit. TkinterContinue Reading

Typically, a tkinter widget allows you to change its appearance based on a specific state. The following table shows a list of widget states and their meanings: State Meaning active The mouse is currently within the widget. alternate Ttk reserved this state for application use. background The widget is on a windowContinue Reading

Introduction to ttk elements So far, you have learned that a theme is a collection of styles that defines the appearance of all Tkinter widgets. A style is a description of the appearance of a widget class. A style is composed of one or more elements. For example, a Label consists of border, padding and label elements. And these elements are nestedContinue Reading

Introduction to the ttk styles A theme of a collection of styles that determine the appearances of Tkinter widgets. A style is a description of the appearance of a widget class. Typically, a theme comes with a predefined set of styles. Therefore, to change the appearance of ttk widgets, you can: Generally, theContinue Reading

Introduction to Tkinter ttk themes In Tkinter, a theme determines the “look & feel” of all the widgets. It’s a collection of styles for all the ttk widgets. A style specifies the appearance of a widget class e.g., a Button. Each theme comes with a set of styles. It’s possible to change theContinue Reading