GUI 登录窗口
import PySimpleGUI as sg
sg.theme('darkAmber')
dict1={'admin':'123456'} #测试用的账号密码
def denlu():
if dict1.get(values['-ID-'],None):
if values['-MI-']==dict1[values['-ID-']]:
print('登陆成功')
else:
print('密码错误')
else:
print('用户不存在!')
def zhuc():
pass
def xiugai():
pass
test1_layout = [
[sg.T('用户名\t'), sg.In('',key='-ID-',size=(30,1),pad=(5,15))],
[sg.T('密码\t'), sg.In('',key='-MI-',size=(30,1),password_char='*',pad=(5,15))],
[sg.B('登录',size=(25,1),pad=(100,15))]]
test2_layout = [
[sg.T('用户名\t'), sg.In('',key='-ZCID-',size=(30,2))],
[sg.T('密码1\t'), sg.In('',key='-ZCMI1-',size=(30,2),password_char='*')],
[sg.T('密码2\t'), sg.In('',key='-ZCMI2-',size=(30,2),password_char='*')],
[sg.T('邮箱\t'), sg.In('',key='-ZCYX-',size=(30,2))],
[sg.B('确定注册',size=(20,1),pad=(100,10))],
]
test3_layout = [
[sg.T('用户名\t'), sg.In('',key='-XGID-',size=(30,2))],
[sg.T('密码\t'), sg.In('',key='-XGMI-',size=(30,2),password_char='*')],
[sg.T('新密码1\t'), sg.In('',key='-XGMI1-',size=(30,2),password_char='*')],
[sg.T('新密码2\t'), sg.In('',key='-XGMI2-',size=(30,2),password_char='*')],
[sg.B('确定修改',size=(20,1),pad=(100,10))],
]
layout = [[sg.TabGroup([[sg.Tab('x x登录x x ',test1_layout, key='-界面登录-', background_color=None,),
sg.Tab('注 册 信 息 ',test2_layout, key='-界面注册-', background_color=None,),
sg.Tab('修 改 信 息 ',test3_layout, key='-界面修改-', background_color=None,),
]],key='-选项-')],]
window = sg.Window('python GUI', layout,font=('微软雅黑', 12),resizable=False,)
while True:
event, values = window.read() # 按键传值
print(event, values)
if event == None: # 关闭窗口
break
if event == '登录':
denlu()
window.close() # 关闭程序