我有这个主题kv 不正确中描述的相同问题。当我使用 Builder 并加载 kv 文件时,我有正常工作的应用程序。但是当我尝试使用自动加载 kv 文件时,我只有黑屏。有人可以解释我为什么吗?谢谢你的帮助。
我的代码。主文件
import kivy
kivy.require('1.9.1') # replace with your current kivy version !
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
class MainScreen(Screen):
pass
class AnotherScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
class Test(App):
def build(self):
return ScreenManagement()
if __name__ == "__main__":
Test().run()
.kv 文件。测试.kv
#:kivy 1.9.1
#: import FadeTransition kivy.uix.screenmanager.FadeTransition
ScreenManagement:
transition: FadeTransition()
MainScreen:
AnotherScreen:
<MainScreen>:
name: "main"
Button:
on_release: app.root.current = "other"
text: "Next Screen"
font_size: 50
<AnotherScreen>:
name: "other"
Button:
on_release: app.root.current = "main"
text: "Prev Screen"
font_size: 50