我正在用Kivy和Python构建一个应用程序,并且正在我的屏幕之间添加导航。目前,该应用程序在点击欢迎页面时崩溃
以下是我的屏幕管理器的代码结构,以及屏幕:
class SwitchingScreenApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(WelcomeScreen(name="welcome"))
sm.add_widget(SignupScreen(name="signup"))
sm.add_widget(ThanksScreen(name="thanks"))
sm.current = "welcome"
return sm
class WelcomeScreen(Screen):
def __init__(self, **kwargs):
super(WelcomeScreen, self).__init__(**kwargs)
box = BoxLayout(orientation='vertical')
welcomeLabel = Label(text='Welcome!',
halign= 'center', font_size=32, color=(0,0,0,1))
image = Image(source="logo.png", allow_stretch=True, keep_ratio=True)
nextLabel = Label(text='Touch anywhere to proceed.',
halign= 'center', font_size=24, color=(0,0,0,1))
box.add_widget(welcomeLabel)
box.add_widget(image)
box.add_widget(nextLabel)
self.add_widget(box)
def callback(self):
print('The button has been pressed')
self.manager.current = 'signup'
SwitchingScreenApp().run()
目前,当我触摸屏幕时,应用程序崩溃,原因是
File "/home/pi/Terminal2/main.py", line 350, in on_motion
self.manager.current = 'success'
AttributeError: 'WindowSDL' object has no attribute 'manager'
我不知道还有什么地方可以看,因为我遵循了这篇文章的答案:python- Kivy Screen Manager within .py file
我的实现中缺少了什么
目前没有回答
相关问题 更多 >
编程相关推荐