graphical user interface (GUI)
A graphical user interface (GUI) is a visual way of interacting with a program through windows, buttons, menus, and other on-screen elements. Instead of typing text commands in a terminal, users interact through actions like clicking, dragging, dropping, and scrolling. Most desktop and mobile applications use GUIs.
In Python, the standard library includes tkinter for building GUIs with basic widgets like labels, buttons, text fields, and drop-down menus.
For more complex applications, third-party libraries like PyQt and PySide provide richer widget sets and tools, such as a visual form designer.
Unlike a command-line interface (CLI), a GUI doesn’t require users to memorize commands, but it typically takes more code to build.
Example
A minimal GUI app built with tkinter:
import tkinter as tk
root = tk.Tk()
root.title("Greeting")
label = tk.Label(root, text="Hello, Pythonista!")
label.pack(padx=20, pady=20)
root.mainloop()
Running this script opens a small window that displays the text “Hello, Pythonista!”
Related Resources
Tutorial
Python GUI Programming: Your Tkinter Tutorial
Complete an interactive tutorial for Python's GUI library Tkinter. Add buttons, text boxes, widgets, event handlers, and more while building two GUI apps.
For additional information on related topics, take a look at the following resources:
- Python and PyQt: Building a GUI Desktop Calculator (Tutorial)
- Build a Tic-Tac-Toe Game With Python and Tkinter (Tutorial)
- PyQt Layouts: Create Professional-Looking GUI Applications (Tutorial)
- How to Build a Python GUI Application With wxPython (Tutorial)
- Build a Mobile Application With the Kivy Python Framework (Tutorial)
- PySimpleGUI: The Simple Way to Create a GUI With Python (Tutorial)
- Qt Designer and Python: Build Your GUI Applications Faster (Tutorial)
- Python and PyQt: Creating Menus, Toolbars, and Status Bars (Tutorial)
- Building a Python GUI Application With Tkinter (Course)
- Python GUI Programming With Tkinter (Quiz)
- Build a GUI Calculator With PyQt and Python (Course)
- Creating PyQt Layouts for GUI Applications (Course)
- Build Cross-Platform GUI Apps With Kivy (Course)
- Simplify Python GUI Development With PySimpleGUI (Course)