Python module to allow learners to easily create GUIs
npx @tessl/cli install tessl/pypi-guizero@1.6.0A Python 3 GUI library designed specifically for educational purposes and new learners to create simple graphical user interfaces. Built on top of the standard Python Tkinter library, it abstracts away complex concepts like StringVar objects and provides an accessible widget naming system that helps beginners build mental models of GUI development. The library generates helpful error messages for learners and requires no additional dependencies beyond Python's standard installation.
pip install guizeroimport guizeroFor commonly used widgets and dialogs:
from guizero import App, Box, Text, TextBox, PushButton, CheckBoxAll widgets and dialogs:
from guizero import *from guizero import App, Text, TextBox, PushButton
# Create main application window
app = App(title="My First GUI", width=300, height=200)
# Add widgets to the app
message = Text(app, text="Hello World!")
name_box = TextBox(app)
def say_hello():
message.value = f"Hello {name_box.value}!"
hello_button = PushButton(app, text="Say Hello", command=say_hello)
# Run the application
app.display()guizero follows a hierarchical widget architecture:
All widgets inherit common properties for styling (color, size, font) and behavior (enabled, visible, events). The library uses automatic layout management by default but supports grid-based positioning for precise control.
Core application window functionality including creating the main app window, secondary windows, and handling the application lifecycle.
class App:
def __init__(self, title="guizero", width=500, height=500, layout="auto",
bg=None, visible=True): ...
def display(self): ...
def destroy(self): ...
class Window:
def __init__(self, master, title="guizero", width=500, height=500,
layout="auto", bg=None, visible=True): ...
def show(self): ...
def hide(self): ...Layout containers for organizing and grouping other widgets including boxes, titled frames, and button groups.
class Box:
def __init__(self, master, layout="auto", grid=None, align=None,
visible=True, enabled=None, width=None, height=None,
border=None): ...
class TitleBox:
def __init__(self, master, text="TitleBox", layout="auto", grid=None,
align=None, visible=True, enabled=None, width=None,
height=None, border=None): ...
class ButtonGroup:
def __init__(self, master, options=[], selected=None, horizontal=True,
command=None, grid=None, align=None, visible=True,
enabled=None, width=None, height=None): ...Interactive widgets for user input including buttons, text entry, checkboxes, sliders, and selection widgets.
class PushButton:
def __init__(self, master, command=None, args=None, text="Button",
image=None, pady=10, padx=10, grid=None, align=None,
icon=None, visible=True, enabled=None, width=None,
height=None): ...
class TextBox:
def __init__(self, master, text="", width=10, height=1, multiline=False,
scrollbar=False, command=None, grid=None, align=None,
visible=True, enabled=None, hide_text=False): ...
class CheckBox:
def __init__(self, master, text="", command=None, grid=None, align=None,
visible=True, enabled=None, width=None, height=None): ...
class Slider:
def __init__(self, master, start=0, end=100, horizontal=True, command=None,
grid=None, align=None, visible=True, enabled=None,
width=None, height=None): ...
class Combo:
def __init__(self, master, options=[], selected=None, command=None,
grid=None, align=None, visible=True, enabled=None,
width=None, height=None): ...
class ListBox:
def __init__(self, master, items=[], selected=None, command=None,
multiselect=False, scrollbar=False, grid=None, align=None,
visible=True, enabled=None, width=None, height=None): ...Widgets for displaying text, images, and graphics including text labels, pictures, drawing canvas, and pixel grids.
class Text:
def __init__(self, master, text="", size=None, color=None, bg=None,
font=None, grid=None, align=None, visible=True,
enabled=None, width=None, height=None): ...
class Picture:
def __init__(self, master, image=None, grid=None, align=None,
visible=True, enabled=None, width=None, height=None): ...
class Drawing:
def __init__(self, master, width=400, height=400, grid=None, align=None,
visible=True, enabled=None): ...
class Waffle:
def __init__(self, master, height=3, width=3, dim=20, pad=5,
color="white", dotty=False, grid=None, align=None,
visible=True, enabled=None, remember=True, command=None): ...Message boxes and file/color selection dialogs for user interaction including warnings, information, questions, and file operations.
def warn(title, text, master=None): ...
def info(title, text, master=None): ...
def error(title, text, master=None): ...
def yesno(title, text, master=None): ...
def question(title, question, initial_value=None, master=None): ...
def select_file(title="Select file", folder=".", filetypes=[["All files", "*.*"]],
save=False, master=None, filename=""): ...
def select_folder(title="Select folder", folder=".", master=None): ...
def select_color(color=None, master=None): ...Menu bar functionality for creating application menus and menu items.
class MenuBar:
def __init__(self, master, toplevel=[], options=[]): ...All guizero widgets share common properties and methods:
# Common properties available on all widgets
widget.master # Parent widget
widget.tk # Underlying tkinter object
widget.enabled # Enable/disable state (bool)
widget.visible # Show/hide state (bool)
widget.width # Widget width
widget.height # Widget height
widget.bg # Background color
widget.text_color # Text color (for text-containing widgets)
widget.text_size # Text size (for text-containing widgets)
widget.font # Font family (for text-containing widgets)
# Common methods
widget.destroy() # Remove widget
widget.focus() # Give keyboard focus
widget.resize(width, height) # Change sizeguizero provides simple event handling through widget properties:
# Event handlers can be assigned to widget properties
button.when_clicked = callback_function
textbox.when_key_pressed = key_handler
app.when_closed = cleanup_functionguizero supports multiple layout approaches:
Colors can be specified using:
guizero provides helpful error messages designed for learners:
from guizero.utilities import GUIZeroException
# Custom exception class for guizero-specific errors
class GUIZeroException(Exception): ...