关于弹窗的各种元素:
import PySimpleGUI as sg
sg.popup('你好!!!', '你已进入bug界面!(#^.^#)',
title='万恶的弹窗',
button_color=('red', 'black'),
background_color='black',
text_color='red',
auto_close=None,
auto_close_duration=None,
custom_text=('Yes', 'No'),
non_blocking=None,
font=('宋体', 12),
no_titlebar=False,
grab_anywhere=False,
keep_on_top=False,
location=(None, None),
any_key_closes=None,
image=None,
modal=True
)
print('hiahiahiahiahiahia')
title:弹窗标题
button_color:(文本颜色,背景颜色)
background_color:弹窗背景颜色
text_color:弹窗上的文本背景
auto_close_duration:自动关闭窗口之前界面持续的时间
custom_text = (None, None):自定义按钮上要显示的文本,可以设定一个或两个
non_blocking:非阻塞设定,若为True,立即执行下一步,不需要等待用户
font:(字体名称,字体大小)
no_titlebar:不显示标题
grab_anywhere:若为True,拖动界面进行移动
keep_on_top:True,保持界面在屏幕的最前方
location=(None, None):界面出现在电脑屏幕上的位置
any_key_closes:True,任意的键盘可以关闭页面;False,只能用x窗口关闭按钮,用户选择, 以及回车键才会关闭窗口。
modal:模态窗口设定,除非关闭此窗口否则其他界面不能进行操作
image:显示图片
弹窗之PopupGetText:
import PySimpleGUI as sg
mima = '1234'
list_1 = ['python学习资料', 'java学习资料', 'php学习资料']
while True:
result = sg.PopupGetText('密码输入框')
if result == mima:
break
elif result == None:
exit()
else:
sg.popup('笨蛋,连自己密码都记不住!仄')
layout = [
[sg.LB(list_1, size=(30, 5))],
]
window = sg.Window('资料查询', layout)
while True:
event, values = window.read()
if event == None:
break
window.close()
各种不同特征的弹窗:
import PySimpleGUI as sg
result = sg.PopupGetFile('文件选择弹窗')
print(result)
result = sg.PopupGetFolder('文件夹选择弹窗')
print(result)
result = sg.PopupAnnoying('无标题栏弹窗,可任意移动')
print(result)
result = sg.PopupAutoClose('显示一段时间自动关闭')
print(result)
result = sg.PopupCancel('含有一个Cancelled的按钮')
print(result)
result = sg.PopupOKCancel('含有一个OK和Cancelled的按钮')
print(result)
result = sg.PopupError('含有一个带颜色的Error按钮')
print(result)
result = sg.PopupNoButtons('显示无按钮的弹窗')
print(result)
result = sg.PopupNoWait('显示弹出窗口并立即返回')
print(result)
今天的分享结束!