建立标签
sg.Text(" e-mail ")
建立单行文本框
sg.Text(“password”)
建立按钮
sg.Button(‘OK’)
建立布局
layout = [
[text, text_entry], #第一行左边,第一行右边
[text1, text1_entry], #第二行左边,第二行右边
[ok_btn, cancel_btn]#第三行左边,第三行右边
]
建立窗体
window = sg.Window(‘PySimpleGUI’, layout)#把布局放入窗体
建立消息框
sg.popup(values[0])
监视窗体变化
while True:pass
鼠标事件
if event in (None, ‘OK’):pass
# -*- coding: utf-8 -*-
import PySimpleGUI as sg
text = sg.Text(" e-mail ")
text_entry = sg.InputText()
text1 = sg.Text("password")
text1_entry = sg.InputText()
ok_btn = sg.Button('OK')
cancel_btn = sg.Button('Cancel')
layout = [[text, text_entry],
[text1, text1_entry],
[ok_btn, cancel_btn]]
window = sg.Window('PySimpleGUI', layout)
while True:
event, values = window.read()
if event == None:
break
if event in (None, 'OK'):
#print(f'Event: {event}')
print(str(values))
sg.popup(values[0])
if event in (None, 'Cancel'):
break;
window.close()
说明,自认为最简单的界面,偶尔看到,直接就能查询资料上手。