Python‎ > ‎

Python GUI For Humans! Create full function Python interfaces with PySimpleGUI

posted Aug 9, 2020, 10:04 AM by Chris G   [ updated Aug 9, 2020, 10:06 AM ]

$ 𝚙𝚒𝚙 𝚒𝚗𝚜𝚝𝚊𝚕𝚕 𝚙𝚢𝚜𝚒𝚖𝚙𝚕𝚎𝚐𝚞𝚒

GitHub https://github.com/PySimpleGUI/
Docs https://pysimplegui.readthedocs.io/en/latest/

pysimplegui_logo

This Code

import PySimpleGUI as sg

sg.theme('DarkAmber')   # Add a touch of color
# All the stuff inside your window.
layout = [  [sg.Text('Some text on Row 1')],
            [sg.Text('Enter something on Row 2'), sg.InputText()],
            [sg.Button('Ok'), sg.Button('Cancel')] ]

# Create the Window
window = sg.Window('Window Title', layout)
# Event Loop to process "events" and get the "values" of the inputs
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
        break
    print('You entered ', values[0])

window.close()

Makes This Window

and returns the value input as well as the button clicked.

image

Activate link to view larger image.

This Code

import PySimpleGUI as sg

sg.theme('DarkAmber')   # Add a touch of color
# All the stuff inside your window.
layout = [  [sg.Text('Some text on Row 1')],
            [sg.Text('Enter something on Row 2'), sg.InputText()],
            [sg.Button('Ok'), sg.Button('Cancel')] ]

# Create the Window
window = sg.Window('Window Title', layout)
# Event Loop to process "events" and get the "values" of the inputs
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == 'Cancel': # if user closes window or clicks cancel
        break
    print('You entered ', values[0])

window.close()

Makes This Window

and returns the value input as well as the button clicked.

image

Comments