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   Hiro_R  阅读(49)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示