屏幕管理器:屏幕更改无效

时间:2018-12-08 16:42:33

标签: python kivy

我正在尝试使用on_release事件上的屏幕管理器来更改屏幕,但是当按下按钮时什么也没有发生。 这是python代码:

class Information(ScreenManager):
    pass

class SlothFacts(Screen):
    pass

class KiwiFacts(Screen):
    pass

class MainPanel(GridLayout):
    pass

Builder.load_file("mainPanel.kv")

class Complex(App):
    def build(self):
        return MainPanel()

if __name__ == "__main__":
    Complex().run()

mainPanel.kv文件:

#:include navigation.kv
#:include images.kv
#:include config.kv
#:include information.kv

<MainPanel>:
    cols:2
    Navigation:
    Images:
    Config:
    Information:

和information.kv文件:

#: import  FadeTransition kivy.uix.screenmanager.FadeTransition

<Information>
    transition: FadeTransition()
    SlothFacts:
    KiwiFacts:

<SlothFacts>:
    name: "sloth"
    Button:
        on_release: app.root.current = "kiwi"
        text:"im sloth"

<KiwiFacts>:
    name: "kiwi"
    Button:
        on_release: app.root.current = "sloth"
        text:"im kiwi"

谢谢您的回答。

0 个答案:

没有答案