Как я могу заставить позицию Kivy Scrollview оставаться на одном и том же месте на разных экранах после их перехода?

Рейтинг: 1Ответов: 0Опубликовано: 07.04.2023

пример я полистал скролл перешёл на другой экран хочу чтобы скролл был на том же месте

#: import WipeTransition kivy.uix.screenmanager.WipeTransition

ScreenManagement:
    transition: WipeTransition()
    Link:
    German:
    Morandi:
    Ogr:
    Simon:
<Link>:
    name: "link"
    md_bg_color: 1,1,1,1

    GridLayout:
        rows: 3
        #md_bg_color: app.theme_cls.primary_color
        MDTopAppBar:
            anchor_title: 'center'
            title: "Freak Sounds"
            #right_action_items: [["dots-vertical", lambda x:x]]
            #margin: 0
            #shadow_color: "brown"
            elevation: 0
            md_bg_color: 1,1,1,1
            specific_text_color: app.theme_cls.primary_color
        ScrollView:
            size_hint_y: None
            height: "150dp"
            MDBoxLayout:
                adaptive_width: True
                padding: "20dp","5dp","20dp","15dp"
                spacing: "20dp"
                RelativeLayout:
                    height: "110dp"
                    width: "90dp"
                    #adaptive_size: True
                    size_hint: None, None
                    MDCard:
                        size_hint: None, None
                        elevation: 0
                        radius: "53dp"
                        size: "96dp","96dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        md_bg_color: (255/255.0,54/255.0,79/255.0,255/255.0)
                        #md_bg_color: 0,0,0,0.5
                    MDCard:
                        size_hint: None, None
                        radius: "53dp"
                        size: "94dp","94dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        md_bg_color: 1, 1, 1, 1
                    #FitImage:
                        #size_hint: 1, 1
                        #source: "link.png"
                        #radius: "53dp"
                        #pos_hint: {"center_x": .5, "center_y": .7}
                    CircularRippleButton:
                        source: "link.png"
                        size_hint: None, None
                        size: "90dp", "90dp"
                        #icon_size: "65sp"
                        #icon: ""
                        #ripple_color: (32/255.0,181/255.0,255/255.0,55/255.0)
                        #size_hint: None, None
                        #size: "250dp", "250dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                    MDLabel:
                        text: "VJLink"
                        halign: "center"
                        pos_hint: {"center_x": 0.5, "center_y": 0.1}
                        font_style: "H6"
                        font_size: "13sp"
                        #color: 1,1,1,1
                RelativeLayout:
                    height: "110dp"
                    width: "90dp"
                    size_hint: None, None
                    MDCard:
                        size_hint: None, None
                        radius: "53dp"
                        size: "95dp","95dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        md_bg_color: 1, 1, 1, 1
                    CircularRippleButton:
                        source: "german.png"
                        size_hint: None, None
                        size: "90dp", "90dp"
                        #icon_size: "65sp"
                        #icon: ""
                        #ripple_color: (32/255.0,181/255.0,255/255.0,55/255.0)
                        pos_hint: {"center_x": .5, "center_y": .7}
                        on_press:
                            app.perehod()
                        on_release:
                            #app.root.current = "german"
                            root.manager.transition.direction = "left"
                            root.manager.current = 'german'
                    MDLabel:
                        text: "Герман Ягодка"
                        halign: "center"
                        font_style: "H6"
                        pos_hint: {"center_x": 0.5, "center_y": 0.1}
                        font_size: "13sp"
                        #color: 1,1,1,1
                RelativeLayout:
                    height: "110dp"
                    width: "90dp"
                    size_hint: None, None
                    MDCard:
                        size_hint: None, None
                        radius: "53dp"
                        size: "95dp","95dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        md_bg_color: 1, 1, 1, 1
                    #FitImage:
                        #source: "morandi.png"
                        #size_hint: 1, 1
                        #radius: "53dp"
                        #pos_hint: {"center_x": .5, "center_y": .7}
                    CircularRippleButton:
                        source: "morandi.png"
                        size_hint: None, None
                        size: "90dp", "90dp"
                        #icon_size: "65sp"
                        #icon: ""
                        #ripple_color: (32/255.0,181/255.0,255/255.0,55/255.0)
                        pos_hint: {"center_x": .5, "center_y": .7}
                        on_press:
                            app.perehod()
                        on_release:
                            root.manager.current = 'morandi'
                            root.manager.transition.direction = "left"
                    MDLabel:
                        text: "Эдик Моранди"
                        halign: "center"
                        font_style: "H6"
                        pos_hint: {"center_x": 0.5, "center_y": 0.1}
                        font_size: "13sp"
                        #color: 1,1,1,1
                RelativeLayout:
                    height: "110dp"
                    width: "90dp"
                    size_hint: None, None
                    MDCard:
                        size_hint: None, None
                        radius: "53dp"
                        size: "95dp","95dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        md_bg_color: 1, 1, 1, 1
                    #FitImage:
                        #size_hint: 1, 1
                        #source: "link.png"
                        #radius: "53dp"
                        #pos_hint: {"center_x": .5, "center_y": .7}
                    CircularRippleButton:
                        source: "ogr.png"
                        size_hint: None, None
                        size: "90dp", "90dp"
                        #icon_size: "65sp"
                        #icon: ""
                        #ripple_color: (32/255.0,181/255.0,255/255.0,55/255.0)
                        #size_hint: None, None
                        #size: "250dp", "250dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        on_press:
                            app.perehod()
                        on_release:
                            root.manager.current = 'ogr'
                            root.manager.transition.direction = "left"
                    MDLabel:
                        text: "Данный Огр"
                        halign: "center"
                        pos_hint: {"center_x": 0.5, "center_y": 0.1}
                        font_style: "H6"
                        font_size: "13sp"
                        #color: 1,1,1,1
                RelativeLayout:
                    height: "110dp"
                    width: "90dp"
                    size_hint: None, None
                    MDCard:
                        size_hint: None, None
                        radius: "53dp"
                        size: "95dp","95dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        md_bg_color: 1, 1, 1, 1
                    #FitImage:
                        #size_hint: 1, 1
                        #source: "link.png"
                        #radius: "53dp"
                        #pos_hint: {"center_x": .5, "center_y": .7}
                    CircularRippleButton:
                        source: "simon.png"
                        size_hint: None, None
                        size: "90dp", "90dp"
                        #icon_size: "65sp"
                        #icon: ""
                        #ripple_color: (32/255.0,181/255.0,255/255.0,55/255.0)
                        #size_hint: None, None
                        #size: "250dp", "250dp"
                        pos_hint: {"center_x": .5, "center_y": .7}
                        on_press:
                            app.perehod()
                        on_release:
                            root.manager.current = 'simon'
                            root.manager.transition.direction = "left"
                    MDLabel:
                        text: "Дон Симон"
                        halign: "center"
                        pos_hint: {"center_x": 0.5, "center_y": 0.1}
                        font_style: "H6"
                        font_size: "13sp"
                        #color: 1,1,1,1

# py

from kivy.core.audio import SoundLoader
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.behaviors import ButtonBehavior
from kivymd.uix.tab import MDTabsBase
from kivy.uix.image import Image
from kivymd.uix.behaviors import CircularRippleBehavior
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.app import MDApp
from kivymd.theming import ThemeManager
from kivymd.uix.screen import MDScreen

class ScreenManagement(ScreenManager):
    pass
class CircularRippleButton(CircularRippleBehavior, ButtonBehavior, Image):
    pass


class Link(MDScreen):
    pass
class German(MDScreen):
    pass
class Morandi(MDScreen):
    pass
class Ogr(MDScreen):
    pass
class Simon(MDScreen):
    pass
class MyApp(MDApp):
    theme_cls = ThemeManager()
    def perehod(self):
        e = SoundLoader.load("perehod.mp3")
        e.play()
    # title = "Ебатория"

    def build(self):
        self.theme_cls.theme_style = "Light"
        self.theme_cls.primary_palette = "Orange"
        self.theme_cls.material_style = "M3"
        # self.theme_cls.accent_palette = "Red"
        # self.theme_cls.primary_hue = "400"
        # self.icon = 'qwer.png'
        Builder.load_file('simon.kv')
        Builder.load_file('ogr.kv')
        Builder.load_file('morandi.kv')
        Builder.load_file('german.kv')
        f = Builder.load_file('link.kv')

        return f


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

Ответы

Ответов пока нет.