In this article we want to learn How to Install Tkinter in Windows & Linux, so first of all let’s talk about TKinter.
What is TKinter ?
Tkinter is built in graphical user interface (GUI) library for Python programming language. It provides a way to create graphical user interfaces (GUIs) with Python, using the Tk GUI toolkit. Tkinter provides different set of widgets (e.g buttons, text boxes, etc.) and tools to create and manage windows, dialogs and other GUI elements. Tkinter is easy to use and widely used for creating desktop applications in Python.
How to Install Tkinter in Windows & Linux ?
Windows:
- Tkinter is preinstalled in Python for Windows, no separate installation is required.
- To check if Tkinter is installed, run the following command in the Python terminal: import tkinter
- If there’s no error, Tkinter is installed.
Linux:
- Tkinter is preinstalled in Python for Linux, no separate installation is required.
- To check if Tkinter is installed, run the following command in the Python terminal: import tkinter
- If there’s no error, Tkinter is installed.
- If Tkinter is not installed, you can install it using the package manager of your Linux distribution. E.g., for Ubuntu, you can use the following command: sudo apt-get install python3-tk
Which Kind of GUI Apps I Can Make with TKinter ?
With Tkinter you can create different types of GUI based applications such as:
- Desktop applications with a graphical user interface.
- Multi Window applications.
- Database driven applications.
- Applications with simple dialogs and pop-up windows.
- Applications with charts, graphs and images.
- Custom widgets and controls for GUI.
Tkinter provides comprehensive set of GUI building blocks, making it a suitable tool for building simple to complex GUI applications.
This is an example of a simple Tkinter application that displays greeting message:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import tkinter as tk def greet(): label.config(text="Hello, Tkinter!") root = tk.Tk() root.title("Simple Tkinter App") label = tk.Label(root, text="Welcome to Tkinter!") label.pack() greet_button = tk.Button(root, text="Greet", command=greet) greet_button.pack() root.mainloop() |
When you run the above code, it will create a window with label and button. when you click the button, the text of the label will change to “Hello, Tkinter!”.
This is the image result

Learn More on Python
- Python Best Libraries for Web Development
- How to Make an Instagram Bot
- How to send Message to Instagram with Python
- Build Python REST API with FastAPI
- Python Best Frameworks for Web Development
- Why to Use Python for Web Development
- Python Top 10 Packages to Learn
This is an example of the same simple Tkinter application, but this time using Object Oriented Programming (OOP) approach:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import tkinter as tk class Application(tk.Frame): def __init__(self, master=None): super().__init__(master) self.pack() self.create_widgets() def create_widgets(self): self.label = tk.Label(self, text="Welcome to Tkinter!") self.label.pack() self.greet_button = tk.Button(self, text="Greet", command=self.greet) self.greet_button.pack() def greet(self): self.label.config(text="Hello, Tkinter!") root = tk.Tk() root.title("Simple Tkinter App") app = Application(master=root) app.mainloop() |
This time we have defined Application class that inherits from tk.Frame. The __init__ method sets up the frame and creates the widgets. create_widgets method creates the label and button. The greet method changes the text of the label when the button is clicked. When you run this code, it will create the same window as before with label and button.