📔
intro-to-python
search
⌘Ctrlk
📔
intro-to-python
  • An Introduction to Programming in Python (for Business Students)
  • exercises
  • notes
    • python
      • packages
        • The bigquery Package
        • The PySimpleGUI Package
        • The dotenv Package
        • The matplotlib Package
        • The requests Package
        • The altair Package
        • The gspread Package
        • The PyMySQL Package
        • The psycopg2 Package
        • The selenium Package
        • The seaborn Package
        • The pytest Package
        • The SpeechRecognition Package
        • The flask Package
        • The pandas Package
        • The spotipy Package
        • The pipenv Package
        • The nltk Package
        • The sqlalchemy Package
        • The pymongo Package
        • The plotly Package
        • The BeautifulSoup Package
        • The sendgrid Package
        • The fpdf Package
        • The autopep8 Package
        • The tweepy Package
        • The twilio Package
        • The tkinter Package
      • Python Datatypes Overview
      • Control Flow
      • Python Modules
      • Printing and Logging
      • Comments
      • Syntax and Style
      • Functions
      • Variables
      • Errors
      • Docstrings
      • File Management
      • User Inputs
      • Debugging
    • clis
    • Software
    • devtools
    • Information Systems
    • Technology Project Management
    • hardware
    • Environment Variables
  • projects
  • License
  • Exam Prep
  • units
  • Contributor's Guide
gitbookPowered by GitBook
block-quoteOn this pagechevron-down
  1. noteschevron-right
  2. pythonchevron-right
  3. packages

The PySimpleGUI Package

Thanks to @windy030 and @oaw6 for surfacing the capabilities of this package

The PySimpleGUI package provides an application with a graphical user interface capable of being run on a personal computer.

Reference:

  • https://pypi.org/project/PySimpleGUI/arrow-up-right

  • https://github.com/PySimpleGUI/PySimpleGUIarrow-up-right

  • https://github.com/PySimpleGUI/PySimpleGUI/blob/master/PySimpleGUI.pyarrow-up-right

  • https://pysimplegui.readthedocs.io/en/latest/tutorial/arrow-up-right

  • https://pysimplegui.readthedocs.io/en/latest/cookbook/arrow-up-right

  • https://pysimplegui.readthedocs.io/en/latest/#high-level-api-calls-popupsarrow-up-right

  • https://pysimplegui.readthedocs.io/en/latest/#listbox-elementarrow-up-right

  • https://pysimplegui.readthedocs.io/en/latest/#button-elementarrow-up-right

  • https://pysimplegui.readthedocs.io/en/latest/#input-elementsarrow-up-right

  • etc...

hashtag
Installation

Install the PySimpleGUI package:

pip install PySimpleGUI

hashtag
Usage

Usage examples (adapted from the official documentation):

PreviousThe bigquery Packagechevron-leftNextThe dotenv Packagechevron-right

Last updated 6 years ago

  • Installation
  • Usage
import PySimpleGUI as sg

sg.Popup("Hello From PySimpleGUI!", "This is the shortest GUI program ever!")
import PySimpleGUI as sg

layout = [
    [sg.Text("Enter your name"), sg.InputText()],
    [sg.OK()]
]

window = sg.Window("My first GUI").Layout(layout)

button, values = window.Read()

#print(type(values)) #> dict
#print(values) #> {0: 'Polly Professor'}
name = values[0] #> Polly Professor
print("NAME:", name)
import PySimpleGUI as sg

sg.ChangeLookAndFeel("GreenTan")

column1 = [[sg.Text("Column 1", background_color="#d3dfda", justification="center", size=(10, 1))],
           [sg.Spin(values=("Spin Box 1", "2", "3"), initial_value="Spin Box 1")],
           [sg.Spin(values=("Spin Box 1", "2", "3"), initial_value="Spin Box 2")],
           [sg.Spin(values=("Spin Box 1", "2", "3"), initial_value="Spin Box 3")]]
layout = [
    [sg.Text("All graphic widgets in one window!", size=(30, 1), font=("Helvetica", 25))],
    [sg.Text("Here is some text.... and a place to enter text")],
    [sg.InputText("This is my text")],
    [sg.Checkbox("My first checkbox!"), sg.Checkbox("My second checkbox!", default=True)],
    [sg.Radio("My first Radio!     ", "RADIO1", default=True), sg.Radio("My second Radio!", "RADIO1")],
    [sg.Multiline(default_text="This is the default Text should you decide not to type anything", size=(35, 3)),
     sg.Multiline(default_text="A second multi-line", size=(35, 3))],
    [sg.InputCombo(("Combobox 1", "Combobox 2"), size=(20, 3)),
     sg.Slider(range=(1, 100), orientation="h", size=(34, 20), default_value=85)],
    [sg.Listbox(values=("Listbox 1", "Listbox 2", "Listbox 3"), size=(30, 3)),
     sg.Slider(range=(1, 100), orientation="v", size=(5, 20), default_value=25),
     sg.Slider(range=(1, 100), orientation="v", size=(5, 20), default_value=75),
     sg.Slider(range=(1, 100), orientation="v", size=(5, 20), default_value=10),
     sg.Column(column1, background_color="#d3dfda")],
    [sg.Text("_"  * 80)],
    [sg.Text("Choose A Folder", size=(35, 1))],
    [sg.Text("Your Folder", size=(15, 1), auto_size_text=False, justification="right"),
     sg.InputText("Default Folder"), sg.FolderBrowse()],
    [sg.Submit(), sg.Cancel()]
]

window = sg.Window("Everything bagel", default_element_size=(40, 1)).Layout(layout)
button, values = window.Read()
sg.Popup(button, values)