据说,我有这个。
class MainGui(App):
def build(self):
root = BoxLayout(orientation="vertical")
login_button = Button(text="Let's go")
login_button.bind(on_press = self.login)
login_button_area.add_widget(login_button)
root.add_widget(login_button_area)
def login(self, instance):
pass
现在,当单击 login_button 时,我想将整个布局更改为一个新布局。我该怎么做?
我试过了
def login(self, instance):
root = BoxLayout(orientation='vertical')
textinput = TextInput(text='Hello world', multiline=False)
textinput.bind(on_text_validate=self.on_enter)
root.add_widget(textinput)
return root
请您参考如下方法:
使用kivy.uix.screenmanager。第二个例子来自 documentation (一个带有菜单屏幕和设置屏幕)应该会有用。
