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()
'''
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理