Codementor Events

Python's Built-in GUI kit: Tkinter

Published Mar 24, 2025
Python's Built-in GUI kit: Tkinter

Did you know that python comes with a built-in graphical user interface (GUI) kit?

If you have python installed you can develop GUIs for your applications without downloading any additional dependencies or frameworks!

This is great for small local applications on your desktop, that don't require anyone to open up a browser. It also means your whole project can be done in python!

Here is the link to the tkinter python library reference:
https://docs.python.org/3/library/tkinter.html

Show me the code! Below is a basic tkinter example and what the GUI looks like:

import tkinter as tk

def update_label():
    label.config(text="Hello, Tkinter!")

# Create the main window
root = tk.Tk()
root.title("Basic Tkinter Example")
root.geometry("300x200")

# Create a label
label = tk.Label(root, text="Click the button!")
label.pack(pady=20)

# Create a button
button = tk.Button(root, text="Click Me", command=update_label)
button.pack(pady=10)

# Start the main event loop
root.mainloop()

py_tkinter_gui_example_3.png

This will be run from the command line or how you normally run python programs.

Looking for a more app like feel? You can compile this into a self-extracting python executable using a python compiler like nuitka.

Discover and read more posts from Richard Bailey
get started