Introduction to PySimpleGUI

Last Updated : 17 Jul, 2026

PySimpleGUI is a Python library that simplifies the process of creating graphical user interfaces (GUIs). It provides a simple and beginner-friendly API for building desktop applications with minimal code. Instead of writing complex GUI code, developers can create windows, buttons, text boxes, menus and other interface elements using straightforward Python syntax.

Installation

Before using this library, install the library using pip:

pip install PySimpleGUI

After installation, you can import the library and start building GUI applications. PySimpleGUI includes many built-in elements and ready-to-use examples, making it easy to create desktop applications quickly.

Creating First PySimpleGUI Window

After installing PySimpleGUI, you can create a simple GUI application by defining a layout and displaying it inside a window. The following example creates a window with a text label, an input box, and two buttons.

Python
import PySimpleGUI as sg
sg.theme('BluePurple')

layout = [
    [sg.Text('Your typed characters appear here:'),
     sg.Text(size=(15, 1), key='-OUTPUT-')],
    [sg.Input(key='-IN-')],
    [sg.Button('Display'), sg.Button('Exit')]
]

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

while True:
    event, values = window.read()
    print(event, values)

    if event in (None, 'Exit'):
        break

    if event == 'Display':
        window['-OUTPUT-'].update(values['-IN-'])

window.close()

Output

Explanation:

  • Sets the application theme to BluePurple.
  • Creates a layout containing text, an input field, and two buttons.
  • Creates a window using the defined layout.
  • Waits for user events using window.read().
  • Displays the entered text when the Display button is clicked.
  • Closes the window when the Exit button is pressed or the window is closed.

Common PySimpleGUI Elements

PySimpleGUI provides several built-in elements for creating graphical interfaces.

ElementDescription
TextDisplays text in the window.
InputAccepts user input.
ButtonCreates a clickable button.
CheckboxCreates a checkbox.
RadioCreates radio buttons.
ComboDisplays a drop-down list.
ListboxDisplays a selectable list of items.
ImageDisplays an image.
ProgressBarShows task progress.
MultilineDisplays a multi-line text box.

Working with Buttons and Input Fields

Buttons and input fields are the most commonly used elements in PySimpleGUI. The following example takes the user's name and displays a greeting message.

Python
import PySimpleGUI as sg

layout = [[sg.Text("Enter your name:")],
          [sg.Input(key="-NAME-")],
          [sg.Button("Submit"), sg.Button("Exit")]]

window = sg.Window("Greeting App", layout)

while True:
    event, values = window.read()

    if event in (sg.WIN_CLOSED, "Exit"):
        break

    if event == "Submit":
        sg.popup(f"Hello, {values['-NAME-']}!")

window.close()

Output

Screenshot-2026-07-10-163444
Greeting App
Screenshot-2026-07-10-163510
Display message

Explanation:

  • Creates a text label and an input field.
  • Reads the entered name.
  • Displays a popup message when Submit is clicked.
  • Closes the application when Exit is pressed.

Using Checkboxes and Radio Buttons

PySimpleGUI provides checkboxes and radio buttons to collect user selections.

Python
import PySimpleGUI as sg

layout = [[sg.Checkbox("Python", key="-PY-")],
          [sg.Radio("Beginner", "LEVEL", default=True), sg.Radio("Advanced", "LEVEL")],
          [sg.Button("Show"), sg.Button("Exit")]]

window = sg.Window("Selection Example", layout)

while True:
    event, values = window.read()

    if event in (sg.WIN_CLOSED, "Exit"):
        break

    if event == "Show":
        sg.popup(values)

window.close()

Output

Screenshot-2026-07-10-163958
checkbox and radio button
Screenshot-2026-07-10-164013
Displaying selected values

Explanation:

  • Creates a checkbox and radio buttons.
  • Reads the selected options.
  • Displays the selected values in a popup.

Creating a Drop-Down List

A Combo element allows users to choose one value from a list.

Python
import PySimpleGUI as sg

layout = [[sg.Text("Select a programming language")],
          [sg.Combo(["Python", "Java", "C++", "JavaScript"], default_value="Python", key="-LANG-")],
          [sg.Button("Show"), sg.Button("Exit")]]

window = sg.Window("Combo Example", layout)

while True:
    event, values = window.read()

    if event in (sg.WIN_CLOSED, "Exit"):
        break

    if event == "Show":
        sg.popup("Selected:", values["-LANG-"])

window.close()

Output

Screenshot-2026-07-10-164324
Dropdown list
Screenshot-2026-07-10-164337
displaying selected value

Explanation:

  • Creates a drop-down list.
  • Allows the user to select one option.
  • Displays the selected value in a popup.

Selecting a File

PySimpleGUI includes built-in dialogs for selecting files and folders.

Python
import PySimpleGUI as sg

layout = [[sg.Input(), sg.FileBrowse()],
          [sg.Button("Exit")]]

window = sg.Window("File Browser", layout)

while True:
    event, values = window.read()

    if event in (sg.WIN_CLOSED, "Exit"):
        break

window.close()

Output

Screenshot-2026-07-10-164604
Browsing a file
Screenshot-2026-07-10-164622
selected file

Explanation:

  • Opens the system file browser.
  • Displays the selected file path in the input field.
  • Eliminates the need to create custom file dialogs.

Displaying Popup Messages

Popup windows are useful for displaying messages, warnings, or notifications.

Python
import PySimpleGUI as sg
sg.popup("Welcome to PySimpleGUI!", title="Information")

Output

Screenshot-2026-07-10-164750
alert message

Explanation:

  • Displays a simple popup window.
  • Shows a custom title and message.

Advantages

  • Beginner-Friendly: Uses simple Python syntax, making it easy to learn and build GUI applications.
  • Less Code: Requires fewer lines of code than many traditional GUI frameworks, speeding up development.
  • Ready-to-Use Elements: Provides built-in GUI components such as buttons, text boxes, input fields, tables, and images.
  • Cross-Platform Support: Supports multiple GUI backends, including Tkinter, Qt, WxPython and Remi, allowing applications to run on different platforms.

Applications

  1. Desktop Applications: Create simple desktop software with an interactive graphical interface.
  2. Login and Registration Forms: Design user authentication forms with text fields, buttons, and validation.
  3. File Management Tools: Build applications for selecting, opening, and saving files or folders.
  4. Data Entry Forms: Develop forms to collect and process user input efficiently.
  5. Dashboards: Create simple dashboards to display data, charts, or application status.
  6. Automation Utilities: Build GUI-based tools to automate repetitive tasks and system operations.
Comment