2

I have been learning Kivy with a YouTube channel. I made two screens and one screenmanager but they are classes in python code. I saw examples like WinManager = ScreenManager(transition=CardTransition()) but I didn't structure my code like that. How can i change transition with my code? I tried to do it on init function of class, didn't work; and tried to add transition properity in kv file. Didn't work either.

Python:

from kivy.lang import Builder
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, CardTransition


class MainWindow(Screen):
    pass


class AdminPanel(Screen):
    pass


class WinManager(ScreenManager):
    pass


kvTemplate = Builder.load_file("template.kv")


class MyMainApp(App):
    def build(self):
        return kvTemplate


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

Kivy (.kv):

WinManager:
    MainWindow:
    AdminPanel:

<MainWindow>:
    name: "loginPanel"
    nickname: nicknameID
    password: passwordID
    key: keyID
    GridLayout:
        rows: 2
        GridLayout:
            cols: 2
            Label:
                text: "Nickname: "
            TextInput:
                id: nicknameID
                multiline: False
            Label:
                text: "Password: "
            TextInput:
                id: passwordID
                multiline: False
            Label:
                text: "Key: "
            TextInput:
                id: keyID
                multiline: False
        Button:
            text: "Log in"
            on_release:
                app.root.current = "adminPanel"
                root.manager.transition.direction = "up"

<adminPanel>:
    name: "adminPanel"
    Button:
        text: "Back"
        on_release:
            app.root.current = "loginPanel"
            root.manager.transition.direction = "down"
GKO
  • 23
  • 5

1 Answers1

3

In your kv file you can do:

#:import CardTransition kivy.uix.screenmanager.CardTransition

WinManager:
    transition: CardTransition()
    MainWindow:
    AdminPanel:
John Anderson
  • 35,991
  • 4
  • 13
  • 36