Library Guide

PySimpleGUI

The simplest declarative API for quick forms and internal tools.

Easiest API Wrapper

What Is PySimpleGUI?

PySimpleGUI wraps existing GUI toolkits (primarily tkinter, optionally Qt and wxPython) behind an extremely simple, declarative API. Instead of learning widget classes and geometry managers, you describe your window as a nested list โ€” rows of elements โ€” and read events in a single while True loop. It is designed to get a working form on screen in minutes, not hours.

PySimpleGUI is popular in education, automation scripts, and quick internal tools where development speed matters more than visual polish or architectural purity.

Architecture & Core Concepts

  • Layout โ€” a list of rows; each row is a list of elements: [[Text, Input], [Button]].
  • Window โ€” sg.Window(title, layout) creates the GUI.
  • Event loop โ€” event, values = window.read() blocks until the user acts.
  • Keys โ€” string identifiers (key="-NAME-") to read input values from the values dict.
  • Themes โ€” sg.theme("DarkBlue3") switches color schemes instantly.
  • Porting โ€” change the import to switch backend: import PySimpleGUIQt as sg.

Common elements

ElementPurpose
TextLabels and headings
Input / MultilineText fields
ButtonActions
Checkbox / RadioBoolean / exclusive choice
Combo / ListboxSelections
TableData grids
ProgressBarProgress indication

Installation

shell
pip install PySimpleGUI
pip install PySimpleGUIQt   # optional Qt backend
# Verify licensing terms before commercial use.

Example 1 โ€” Basic form

python
import PySimpleGUI as sg

layout = [[sg.Text("Name:"), sg.Input(key="-N-")],
          [sg.Button("OK"), sg.Button("Exit")]]
window = sg.Window("Demo", layout)

while True:
    event, values = window.read()
    if event in (sg.WIN_CLOSED, "Exit"):
        break
    if event == "OK":
        sg.popup("Hello", values["-N-"])
window.close()

Example 2 โ€” Settings with themes

python
import PySimpleGUI as sg
sg.theme("DarkGrey13")
layout = [
    [sg.Checkbox("Enable logging", key="-LOG-", default=True)],
    [sg.Text("Volume"), sg.Slider((0, 100), orientation="h", key="-VOL-")],
    [sg.Button("Save"), sg.Button("Cancel")],
]
win = sg.Window("Settings", layout, modal=True)
event, vals = win.read(); win.close()

Example 3 โ€” File picker utility

python
layout = [
    [sg.Input(key="-FILE-"), sg.FileBrowse()],
    [sg.Button("Process"), sg.Button("Exit")],
]
win = sg.Window("File tool", layout)
while True:
    ev, vals = win.read()
    if ev in (sg.WIN_CLOSED, "Exit"): break
    if ev == "Process": sg.popup("Selected:", vals["-FILE-"])
win.close()

Practical advice

  • Use descriptive key= strings โ€” they are how you read values back.
  • sg.popup(), sg.popup_get_file() cover most dialog needs.
  • For long operations, use window.perform_long_operation() to avoid freezing.
  • Graduate to Qt or CustomTkinter when complexity grows beyond ~300 lines.

Real-world use cases

  • Quick data-entry dialogs for scripts
  • Automation front-ends (file pickers, option panels)
  • Teaching GUI concepts before full toolkits
  • One-off utilities (rename tools, CSV converters)

โœ“ Strengths

  • Gentlest learning curve of all
  • One explicit, readable event loop
  • Backed by several toolkits
  • Built-in themes and popups

โœ— Weaknesses

  • Less flexible for complex UIs
  • Licensing model changed โ€” check terms
  • Abstraction limits deep customization
  • Not ideal for large, long-lived apps
Use it when

You need a working dialog or form in minutes. Graduate to Tkinter or PySide6 when the project outgrows the layout-as-list model.