Reputation: 11
when I try to set up screen navigation, It produces blank screen without error. my approach is to execute every line I write I am expecting a label and an image Can anyone point out what is wrong with this code. any help will be appreciated
here is my code main.py
import kivy
from kivy.config import Config
Config.set('graphics', 'width', '400')
Config.set('graphics', 'height', '500')
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.uix.screenmanager import ScreenManager,Screen
kv = Builder.load_file("outer.kv")
class Firstwindow(Screen):
pass
class Secondwindow(Screen):
pass
class Thirdwindow(Screen):
pass
class WindowManager(ScreenManager):
def screen_manager_method(self):
print('Hello from screen manager')
class CrashCourse(App):
def build(self):
return kv
if __name__ == '__main__':
CrashCourse().run()
outer.kv
ScreenManager:
id: screen_manager
<Firstwindow>:
name: "home_screen"
id: home_screen
Label:
text:"Enter your name bellow"
Image:
source:"down.jpg"
<Secondwindow>:
name: "menu_screen"
id: menu_screen
<Thirdwindow>:
name: "game_screen"
id: game_screen
Upvotes: 0
Views: 853
Reputation: 38822
When you execute:
kv = Builder.load_file("outer.kv")
the Builder
creates a ScreenManager
and returns that as kv
. The other parts of the kv
file result in rules being loaded. Those rules describe how the Screens
should be built, but they do not build any Screens
. Try replacing:
ScreenManager:
id: screen_manager
with:
ScreenManager:
id: screen_manager
Firstwindow:
Secondwindow:
Thirdwindow:
This should result in a ScreenManager
with three Screens
. See the documentation.
Upvotes: 1