pysimplegui的简单使用

安装pysimplegui

直接 pip install pysimplegui 就好了…没什么好说的。

案例

import PySimpleGUI as sg 
sg.theme('DarkAmber')

# 布局
my_text = sg.Text("my text")
hello_button = sg.Button("hello")
clear_button = sg.Button("clear")
layout = [
    [my_text],
    [hello_button,clear_button]
]
window = sg.Window("My GUI",layout)

# 监听事件
while True:
    event,value = window.read()
    if event == sg.WIN_CLOSED: 
        break
    if event == "hello":
        print("你点击了hello")
    if event == "clear":
        print("清除")

window.close()

 

posted @ 2022-09-09 13:13  波罗斯の程序日记  阅读(154)  评论(0编辑  收藏  举报