PySimpleGUI初体验

  |   0 评论   |   0 浏览

背景

初体验

安装

pip3 install pysimplegui
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting pysimplegui
  Downloading http://mirrors.aliyun.com/pypi/packages/c1/40/21b1afb6d04b287d1566dc95bf2ceb7dc871ed7f18ca54bac07f605c3347/PySimpleGUI-4.35.0-py3-none-any.whl (332kB)
     |████████████████████████████████| 337kB 2.4MB/s
Installing collected packages: pysimplegui
Successfully installed pysimplegui-4.35.0

入门示例

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()

参考