PySimpleGUI

raw JSON →
6.0 verified Fri May 01 auth: no python

PySimpleGUI is a Python package that enables creating simple, cross-platform GUIs with ease. It wraps tkinter, Qt, WxPython, and Remi (web) into a unified API. Current version is 6.0, released in 2026 under LGPL3. New major version with significant API changes and improved theming.

pip install PySimpleGUI
error AttributeError: module 'PySimpleGUI' has no attribute 'Window'
cause Typo or incorrect import. Common mistake: installing 'pysimplegui' (lowercase) instead of 'PySimpleGUI' (capital letters).
fix
Ensure you installed PySimpleGUI with correct casing: pip install PySimpleGUI (case-sensitive on some systems). Then use import PySimpleGUI as sg.
error NameError: name 'sg' is not defined
cause Forgot to import or used wrong import alias.
fix
Add 'import PySimpleGUI as sg' at the top of your script.
breaking Version 6.0 introduced a completely new theming system and deprecated many old theme names. If upgrading from 5.x, existing themes may break.
fix Update theme calls to new API: use sg.theme('DarkBlue3') instead of sg.SetOptions(background_color='...'). Check release notes for full list of changes.
breaking The 'Button' element is now 'Button' (capital B) instead of 'Button' in older versions? Actually, it's always been Button. But in 6.0, the 'OK' button no longer auto-closes the window; you must handle the event explicitly.
fix In event loop, explicitly break when event is 'OK' or sg.WIN_CLOSED.
gotcha Calling window.close() outside the event loop or forgetting to close the window can cause memory leaks or hanging processes.
fix Always call window.close() after the event loop ends. Use try/finally or context manager if available (not in standard API).

Creates a simple window with a text and a button. Uses the standard event loop pattern.

import PySimpleGUI as sg

layout = [[sg.Text('Hello from PySimpleGUI')],
          [sg.Button('OK')]]

window = sg.Window('Demo', layout)

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'OK':
        break

window.close()