FALOS
FALOS

Reputation: 1

does not switch between screens in the file .kv, Kivy

There is no transition between the K5 and** Geo5** screens in .kv file I've read articles on the forum and in the documentation and I don't understand what I'm doing wrong, I'm new to Kivy.I have a screen manager that defines screens. In the Shpora file.kv there is no such problem since the taps are defined in the file .py and the transition to them is quietly carried out from the klass5,kv file.If possible, I don't want to use it in klass5.kv.


ScreenManager:
    K5:
    Geo5:

<K5@Screen>:
    name: "main5klass"

    BoxLayout:
        orientation:"vertical"
        BoxLayout:
            canvas.before:
                Color:
                    rgba: (.47, 1, .35, 1)
                Rectangle:
                    pos: self.pos
                    size: self.size
            padding: "5dp"
            Button:
                background_color: 1, 1, 1, 0
                FloatLayout:
                    pos: self.parent.pos
                    size: self.parent.size
                    orientation: 'lr-tb'
                    Image:
                        source: "images/button1.png"
                        size: self.parent.size
                        pos: self.parent.pos
                        allow_stretch: True
                        keep_ratio: False
                    Label:
                        text:"АЛГЕБРА"
                        pos: self.parent.pos
            Label:
                size_hint: .01 , 1
            Button:
                background_color: 1, 1, 1, 0
                on_press: app.root.current = 'geo5'
                FloatLayout:
                    pos: self.parent.pos
                    size: self.parent.size
                    orientation: 'lr-tb'
                    Image:
                        source: "images/button1.png"
                        size: self.parent.size
                        pos: self.parent.pos
                        allow_stretch: True
                        keep_ratio: False
                    Label:
                        text:"ГЕОМЕТРИЯ"
                        pos: self.parent.pos
        BoxLayout:
            padding: "20dp"
            spacing: "20dp"
            size_hint:1,None
            Button:
                background_color: 1, 1, 1, 0
                on_press: app.root.current = 'menu'
                Image:
                    source: "images/back.png"
                    center_x: self.parent.center_x
                    center_y: self.parent.center_y
            Button:
                background_color: 1, 1, 1, 0
                on_press: app.root.current = 'menu'
                Image:
                    source: "images/home.png"
                    center_x: self.parent.center_x
                    center_y: self.parent.center_y

<Geo5@Screen>:
    name: 'geo5'

    BoxLayout:
        orientation: 'vertical'
        Label:
            text: "Экран геометрии"
            font_size: 24
            color: 1, 1, 1, 1```

Upvotes: 0

Views: 26

Answers (1)

Ralph
Ralph

Reputation: 1

Line 57, 64 - on_press: app.root.current = 'menu' should not be 'menu'. Instead, it should be 'geo5'

Upvotes: 0

Related Questions