PySimpleGUI-2

  ---------------------------------------------------------------------------------------------------------------------文本-------------------------------------------------------------------------------------------------------------------

'''import PySimpleGUI as sg # Part 1 - 导入库

# 定义窗口的内容
layout = [ [sg.Text("请输入基本信息")], # Part 2 - 排版
[sg.Text("请输入密码")],
[sg.Input(tooltip='德州?',password_char='*')],
[sg.Button('确认')] ]

# 创建窗口
window = sg.Window('Window Title', layout) # Part 3 - 窗口定义

# Display and interact with the Window
while True:
event, values = window.read() # Part 4 - 开启主循环 window.read()
password='dzyc@1234'
if event==None:
break
if event =="确认":
# Do something with the information gathered
if values[0]==password:
message='输入正确'
else:
message='输入错误'
sg.Popup(message)
# Finish up by removing from the screen
window.close() # Part 5 - 关闭窗口
'''

--------------------------------------------------------------------------------------------------------------------按钮1-------------------------------------------------------------------------------------------------------------------

################################################按钮


import PySimpleGUI as sg # Part 1 - 导入库

# 定义窗口的内容
layout = [ [sg.B("请输入基本信息",button_color=('white','grey'),
bind_return_key=True)]] # Part 2 - 排版


# 创建窗口
window = sg.Window('Window Title', layout) # Part 3 - 窗口定义

# Display and interact with the Window
while True:
event, values = window.read() # Part 4 - 开启主循环 window.read()
print(event,values)
if event==None:
break
if event =="确认":
# Do something with the information gathered
sg.Popup('Hello', values[0], "! Thanks for trying PySimpleGUI")
if event =="取消":
# Do something with the information gathered
sg.Popup('Hello', values[0], "! Thanks for trying PySimpleGUI")
# Finish up by removing from the screen
window.close() # Part 5 - 关闭窗口

 

############图片转换成base64
'''
import base64
f=open(r'E:\confusions.PNG','rb')
#读取文件转换位base64编码
ls_f=base64.b64encode(f.read())
print(ls_f)
f.close()
'''

 

posted on 2022-01-27 17:45  Hiro_R  阅读(68)  评论(0)    收藏  举报

导航