kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.14k stars 655 forks source link

Transition recovery time #1703

Closed AHiXilTOr closed 2 weeks ago

AHiXilTOr commented 3 weeks ago

Description of the Bug

When you set a Transition, for example, MDSlideTransition and then change to MDSharedAxisTransition, the elements are hidden. A similar effect also occurs with a quick change of MDSlideTransition, etc.

Code and Logs

from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.transition import MDSlideTransition, MDSharedAxisTransition

kv = """
<MainScreen@MDScreen>:

    MDBoxLayout:
        orientation: "vertical"
        pos_hint: {"center_x": 0.5, "center_y": 0.5}
        adaptive_size: True
        spacing: "10dp"

        MDLabel:
            text: "1"
            bold: True
            halign: "center"

        MDButton:
            on_release: app.set_screen("second_screen")
            style: "elevated"

            MDButtonText:
                text: "Next" 

<SecondScreen@MDScreen>:
    orientation: "vertical"

    MDBoxLayout:
        orientation: "vertical"
        pos_hint: {"center_x": 0.5, "center_y": 0.5}
        adaptive_size: True
        spacing: "10dp"

        MDLabel:
            text: "2"
            bold: True
            halign: "center"

        MDButton:
            on_release: app.set_screen("main_screen", "left")
            style: "elevated"

            MDButtonText:
                text: "Previous" 

MDBoxLayout:
    md_bg_color: self.theme_cls.backgroundColor

    MDScreenManager:
        id: screen_manager

        MainScreen:
            name: "main_screen"

        SecondScreen:
            name: "second_screen"
"""

class App(MDApp):
    def build(self):
        return Builder.load_string(kv)

    def set_screen(self, screen_name, direction=None):
        screen_manager = self.root.ids.screen_manager
        if direction:
            screen_manager.transition = MDSlideTransition(direction=direction)
        else:
            screen_manager.transition = MDSharedAxisTransition()
        screen_manager.current = screen_name

App().run()

Versions

T-Dynamos commented 3 weeks ago

@AHiXilTOr Please elaborate, code you attached is working as intended.

AHiXilTOr commented 3 weeks ago

@AHiXilTOr Please elaborate, code you attached is working as intended.

IgIh1dhKML

T-Dynamos commented 3 weeks ago

@AHiXilTOr Are you on master branch? This does not happens with me.

AHiXilTOr commented 3 weeks ago

@T-Dynamos Yes

T-Dynamos commented 2 weeks ago

@AHiXilTOr Please see if issue is resolved:

https://github.com/kivymd/KivyMD/assets/68729523/c86d4511-3539-4a69-a92f-c0f206232ca4

AHiXilTOr commented 2 weeks ago

@T-Dynamos, no, the problem is still the same

AHiXilTOr commented 2 weeks ago

@T-Dynamos I removed the environment and updated python from 3.12.2 to 3.12.4 and everything works as intended

AHiXilTOr commented 2 weeks ago

@T-Dynamos I apologize for writing in closed issues, but what can you say about quick switching using this method, I personally hide content, because I quickly switch from one to another.

from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.transition import MDSlideTransition, MDSharedAxisTransition

kv = """
<MainScreen@MDScreen>:

    MDBoxLayout:
        orientation: "vertical"
        pos_hint: {"center_x": 0.5, "center_y": 0.5}
        adaptive_size: True
        spacing: "10dp"

        MDLabel:
            text: "1"
            bold: True
            halign: "center"

<SecondScreen@MDScreen>:
    orientation: "vertical"

    MDBoxLayout:
        orientation: "vertical"
        pos_hint: {"center_x": 0.5, "center_y": 0.5}
        adaptive_size: True
        spacing: "10dp"

        MDLabel:
            text: "2"
            bold: True
            halign: "center" 

MDBoxLayout:
    orientation: "vertical"
    md_bg_color: self.theme_cls.backgroundColor

    MDScreenManager:
        id: screen_manager

        MainScreen:
            name: "main_screen"

        SecondScreen:
            name: "second_screen"

    MDBoxLayout:

        Widget:

        MDButton:
            on_release: app.set_screen("main_screen", "right")
            pos_hint: {"center_y": 1}
            style: "elevated"

            MDButtonText:
                text: "1"

        MDButton:
            on_release: app.set_screen("second_screen", "left")
            pos_hint: {"center_y": 1}
            style: "elevated"

            MDButtonText:
                text: "2"

        Widget:
"""

class App(MDApp):
    def build(self):
        return Builder.load_string(kv)

    def set_screen(self, screen_name, direction=None):
        screen_manager = self.root.ids.screen_manager
        if direction:
            screen_manager.transition = MDSlideTransition(direction=direction)
        else:
            screen_manager.transition = MDSharedAxisTransition()
        screen_manager.current = screen_name

App().run()