请帮我看一下这段代码。每次我运行它,它显示一个空白屏幕,是kivy的新手。
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager,Screen
from kivy.lang import Builder
class first_screen(Screen):
pass
class second_screen(Screen):
pass
class my_manager(ScreenManager):
pass
Builder.load_file("testing_screens.kv")
class testing_screens(App):
def build(self):
return my_manager()
testing_screens().run()
<my_manager>:
first_screen:
second_screen:
<first_screen>:
name: "one"
Button:
text: "hello peeps"
on_press: app.root.current= "two"
<second_screen>:
name: "two"
Button:
text: "world gurus"
on_press: app.root.current= "one"
代码搞砸了。
答案 0 :(得分:1)
小部件名称必须以大写字母开头才能使kv正常工作,因为它使用它来区分它们与属性。在这种情况下,kv规则认为你创建了两个名为first_screen和second_screen的新属性,而不是你添加了两个小部件。