Python 更新PySimpleGUI中的值
我有一个通过selenium从网站获取数据的机器人,我想在GUI上绘制这些数据。Bot也发送电子邮件和通知,我需要某种方式随时更改Python 更新PySimpleGUI中的值,python,pysimplegui,Python,Pysimplegui,我有一个通过selenium从网站获取数据的机器人,我想在GUI上绘制这些数据。Bot也发送电子邮件和通知,我需要某种方式随时更改real\u Email和real\u noti的值 整个BOT代码位于循环中,而True:循环中 我现在遇到的问题是,我正在考虑将我的BOT代码和pysimplegui添加到同一个while循环中,但程序在事件处停止,values=window.read()用于输入,如果传递了进一步的输入,则不会继续 这是演示代码 import PySimpleGUI as sg
real\u Email
和real\u noti
的值
整个BOT代码位于循环中,而True:
循环中
我现在遇到的问题是,我正在考虑将我的BOT代码和pysimplegui添加到同一个while
循环中,但程序在事件处停止,values=window.read()
用于输入,如果传递了进一步的输入,则不会继续
这是演示代码
import PySimpleGUI as sg
sg.theme('DarkAmber') # Keep things interesting for your users
elem = sg.Text('Email and Notfication ON', key='-TEXT-')
layout = [[elem],
[sg.Input(key='-IN-')],
[sg.Input(key='-IN')],
[sg.Button('Ok'), sg.Exit()]]
window = sg.Window('Window that stays open', layout)
real_email = "On"
real_noti = "On"
while True: # The Event Loop
event, values = window.read()
email = values['-IN-']
notification = values['-IN']
if email == "On":
real_email = "On"
elif email == "Off":
real_email = "Off"
if notification == "On":
real_noti = "On"
elif notification =="Off":
real_noti = "Off"
if event in (None, 'Exit'):
break
print("Testing Print Value After .read()")
window.close()
我只想在这个循环中更改这两个值。可能是使用复选框或仅使用按钮的方法?您必须在
sg中设置enable_event=True
。输入(key='-in-')
将是sg。输入(key='-in-',enable_event=True)
您必须在sg中设置enable_event=True
。输入(key='-in-')
将是sg输入(key='-in-',enable_event=True)
您可以在PySimpleGUI的GitHub上找到许多演示程序。我认为其中一个例子会有帮助。在PySimpleGUI的GitHub上可以找到许多演示程序。我认为其中一个例子会有帮助。