PySimpleGUI 返回 none
PySimpleGUI returning none
当我执行这段代码时,我不明白为什么在我按下后退按钮后它会给出 none。此代码的主要目的是从一个 window 更改为另一个
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()
这可能对你有用:
import PySimpleGUI as sg
class Canvas:
def __init__(self):
self.buttons=[['Safe', 'Env', 'Health', 'Quali'],
['Forms','Checklist','Photos','Back']
]
#Layout
self.lt = [[sg.Button(i)] for i in self.buttons[0]]
#Janela
def Begin(self):
self.windows = sg.Window('A').Layout(self.lt)
while True:
self.event, self.values = self.windows.Read()
#When pressing the button, changing the window
if self.event == 'Safe':
self.windows.Disappear()
self.lt2 = [[sg.Button(i)] for i in self.buttons[1]]
self.windows1 = sg.Window('S').Layout(self.lt2)
while True:
self.event1, self.values1 = self.windows1.Read()
if self.event1 == 'Back':
self.windows1.close()
break
if self.event in (None, 'Exit'):
break
self.windows.reappear()
#Closing part
if self.event in (None, 'Exit'):
break
cv = Canvas()
cv.Begin()
当我执行这段代码时,我不明白为什么在我按下后退按钮后它会给出 none。此代码的主要目的是从一个 window 更改为另一个
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()
这可能对你有用:
import PySimpleGUI as sg
class Canvas:
def __init__(self):
self.buttons=[['Safe', 'Env', 'Health', 'Quali'],
['Forms','Checklist','Photos','Back']
]
#Layout
self.lt = [[sg.Button(i)] for i in self.buttons[0]]
#Janela
def Begin(self):
self.windows = sg.Window('A').Layout(self.lt)
while True:
self.event, self.values = self.windows.Read()
#When pressing the button, changing the window
if self.event == 'Safe':
self.windows.Disappear()
self.lt2 = [[sg.Button(i)] for i in self.buttons[1]]
self.windows1 = sg.Window('S').Layout(self.lt2)
while True:
self.event1, self.values1 = self.windows1.Read()
if self.event1 == 'Back':
self.windows1.close()
break
if self.event in (None, 'Exit'):
break
self.windows.reappear()
#Closing part
if self.event in (None, 'Exit'):
break
cv = Canvas()
cv.Begin()