Python/Kivy Multiple screens not working, Code does not recognise the screen manager?

182 views Asked by At

I am trying to make an app that starts in the main menu, you press the play button and it sends you to the game on a different screen.

Problem is i keep getting an error on the: "kv= Builder.load_file("my.kv")" saying that "WindowManager" is an unknown class.

import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang.builder import Builder
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.vector import Vector
from kivy.uix.floatlayout import FloatLayout

kv= Builder.load_file("my.kv")



class WindowManager(ScreenManager):
    pass


class MenuWindow(Screen):
    pass



class Game(Screen):
    pass

class MyApp(App):
    def build(self):
        return kv




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

AND HERE IS THE KV FILE:

WindowManager:
    MenuWindow:
    Game:

<MenuWindow>:
    name: "Menu"
    FloatLayout:    
        Button:
            text:"Play"
            on_release:
                app.root.current= "Game"



<Game>:
    name: "Game"
0

There are 0 answers