【发布时间】:2020-08-03 03:12:00
【问题描述】:
当我执行这段代码时,我不明白为什么在我按下后退按钮后它给出了一个无。这段代码的主要目的是从一个窗口切换到另一个窗口。
import PySimpleGUI as sg
class Canvas:
def __init__(self):
buttons=[['Safe', 'Env', 'Health', 'Quali'],
['Forms','Checklist','Photos','Back']
]
#Layout
lt = [[sg.Button(i)] for i in buttons[0]]
lt2 = [[sg.Button(i)] for i in buttons[1]]
#Janela
self.windows = [sg.Window('A').Layout(lt),sg.Window('S').Layout(lt2)]
def Begin(self):
i=0
while True:
self.event, self.values = self.windows[i].Read()
#When pressing the button, changing the window
if self.event == 'Safe':
self.windows[i].Close()
i=1
if self.event == 'Back':
i=0
#Closing part
if self.event in (None, 'Exit'):
break
cv = Canvas()
cv.Begin()
【问题讨论】:
标签: button pysimplegui