1 导入库
import PySimpleGUI as sg
2 定义布局,确定行数
layout=[
[sg.Text('请输入您的信息')],
[sg.Text('姓名'),sg.InputText('程序员无声')],
[sg.Text('性别'),sg.InputText('男')],
[sg.Text('国籍'),sg.InputText('汉')],
[sg.Button('确定'),sg.Button('取消')]
]
3 创建窗口
window=sg.Window('Python GUI',layout)
4 事件循环
while True:
event,values=window.read() #窗口的读取,有两个返回值(1.事件 2.值)
if event==None:#窗口关闭事件
break
5 关闭窗口
window.close()
Template
import PySimpleGUI as sg
layout=[
[sg.Text('请输入您的信息')],
[sg.Text('姓名'),sg.InputText('程序员无声')],
[sg.Text('性别'),sg.InputText('男')],
[sg.Text('国籍'),sg.InputText('汉')],
[sg.Button('确定'),sg.Button('取消')]
]
window=sg.Window('Python GUI',layout)
while True:
event,values=window.read() #窗口的读取,有两个返回值(1.事件 2.值)
if event==None:#窗口关闭事件
break
window.close()
评论已关闭