может кто-нибудь помочь мне сделать передачи между экраном в киви. так что я пытаюсь плавно от "part1" к "part2" - PullRequest
0 голосов
/ 04 августа 2020

** «Часть 1», поэтому эта часть является первым экраном, поэтому я пытаюсь передать ее на боковую часть экрана, и я хочу добавить еще несколько виджетов на второй экран, но он должен быть плавным, как будто не скользит влево или право. **

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.animation import Animation
from kivy.properties import NumericProperty
    
    kv = '''
    FloatLayout:
        GUIC:
            size_hint: 
            pos_hint:  
        GUIC2:
            size_hint: 
            pos_hint:   
        GUIC3: 
            size_hint:  
            pos_hint:    
        GUIC4: 
            size_hint:  
            pos_hint:    
        GUIC5: 
            size_hint:  
            pos_hint:    
    
        GUIC6: 
            size_hint:  
            pos_hint:    
    
        GUIC7: 
            size_hint:  
            pos_hint:    
        GUIC8: 
            size_hint:  
            pos_hint:     
        GUIC9: 
            size_hint:  
            pos_hint:    
    
    
    
    
    
      
    <GUIC2>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, -1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 90, 90, 180, 10)
    
    <GUIC3>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, -1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 60, 90, 180, 10)
    
    <GUIC4>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 30, 90, 180, 10)                
    
    <GUIC5>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 0,45 , 10)
    
    <GUIC6>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 90,135 , 10) 
    
    <GUIC7>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 180,225 , 10) 
    
    <GUIC8>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0,1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 270,315 , 10)                                                    
    
    <GUIC9>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0,1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 105, 200,315 , 100)                  
    '''
    
    
    class GUIC(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=9)
            anim += Animation(angle=360, duration=9)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC2(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC2, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=7)
            anim += Animation(angle=360, duration=7)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC3(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC3, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=5)
            anim += Animation(angle=360, duration=5)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC4(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC4, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=3)
            anim += Animation(angle=360, duration=3)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC5(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC5, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC6(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC6, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC7(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC7, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC8(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC8, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC9(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC9, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=10)
            anim += Animation(angle=360, duration=10)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    
    
    
    class TestApp(App):
        def build(self):
            return Builder.load_string(kv)
    
    
    TestApp().run()
    

** «Часть 2», так что это второй экран, где он будет после того, как я нажал на него **

 from kivy.app import App
 from kivy.lang import Builder
 from kivy.uix.floatlayout import FloatLayout
 from kivy.animation import Animation
 from kivy.properties import NumericProperty
    
    kv = '''
    FloatLayout:
        GUIC:
            size_hint: 0.7, 1
            pos_hint: {'right':1.2}  
        GUIC2:
            size_hint: 0.7, 1
            pos_hint: {'right':1.2}   
        GUIC3: 
            size_hint: 0.7, 1 
            pos_hint: {'right': 1.2}   
        GUIC4: 
            size_hint: 0.7, 1 
            pos_hint: {'right': 1.2}  
            
        GUIC5: 
            size_hint: 0.7, 1 
            pos_hint: {'right': 1.2} 
        
        GUIC6: 
            size_hint: 0.7,1 
            pos_hint: {'right': 1.2}
    
        GUIC7: 
            size_hint: 0.7, 1 
            pos_hint: {'right': 1.2} 
          
        GUIC8: 
            size_hint: 0.7, 1 
            pos_hint: {'right': 1.2}  
        GUIC9: 
            size_hint: 0.7, 1 
            pos_hint: {'right': 1.2}     
            
        
                                                          
    <GUIC>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 60, 90, 180, 10)
    <GUIC2>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, -1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 90, 90, 180, 10)
    
    <GUIC3>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, -1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 45, 90, 180, 10)
                    
    <GUIC4>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 30, 90, 180, 10)                
                    
    <GUIC5>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 0,45 , 10)
                    
    <GUIC6>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 90,135 , 10) 
                    
    <GUIC7>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0, 1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 180,225 , 10) 
                    
    <GUIC8>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0,1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 1.
                circle:
                    (root.center_x, root.center_y, 145, 270,315 , 10)                                                    
                                   
    <GUIC9>:
        canvas.before:
            PushMatrix
            Rotate:
                angle: root.angle
                axis: 0, 0,1
                origin:  root.center
        canvas.after:
            PopMatrix
    
    
        canvas:
            Color:
                rgba: .1, 1, .1, .9
            Line:
                width: 5.
                circle:
                    (root.center_x, root.center_y, 105, 200,315 , 100)                  
    '''
    
    
    class GUIC(FloatLayout):
        angle = NumericProperty(0)
        def __init__(self, **kwargs):
            super(GUIC, self).__init__(**kwargs)
            anim = Animation(angle = 360, duration=9)
            anim += Animation(angle = 360, duration=9)
            anim.repeat = True
            anim.start(self)
    
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC2(FloatLayout):
        angle = NumericProperty(0)
        def __init__(self, **kwargs):
            super(GUIC2, self).__init__(**kwargs)
            anim = Animation(angle = 360, duration=7)
            anim += Animation(angle = 360, duration=7)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
                if angle == 360:
                    item.angle = 0
    
    class GUIC3(FloatLayout):
        angle = NumericProperty(0)
        def __init__(self, **kwargs):
            super(GUIC3, self).__init__(**kwargs)
            anim = Animation(angle = 360, duration=5)
            anim += Animation(angle = 360, duration=5)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
                if angle == 360:
                    item.angle = 0
    
    
    class GUIC4(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC4, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=3)
            anim += Animation(angle=360, duration=3)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC5(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC5, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    class GUIC6(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC6, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    class GUIC7(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC7, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class GUIC8(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC8, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=15)
            anim += Animation(angle=360, duration=15)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    class GUIC9(FloatLayout):
        angle = NumericProperty(0)
    
        def __init__(self, **kwargs):
            super(GUIC9, self).__init__(**kwargs)
            anim = Animation(angle=360, duration=10)
            anim += Animation(angle=360, duration=10)
            anim.repeat = True
            anim.start(self)
    
        def on_angle(self, item, angle):
            if angle == 360:
                item.angle = 0
    
    
    class TestApp(App):
        def build(self):
            return Builder.load_string(kv)
    
    
    
    TestApp().run()

** моя общая идея о том, как это работает, так как я новичок в этом, я смотрел видео на YouTube и просматривал inte rnet. Но, насколько мне известно, люди здесь намного более опытны, так почему бы не поучиться у профессионалов, которые действительно знают, что они делают, и так или по списку объяснили это так, как каждый может понять. **

  from kivy.app import App
    from kivy.lang import Builder
    from kivy.uix.screenmanager import ScreenManager, Screen
    
    
    Builder.load_string("""
    <ScreenOne>:
        BoxLayout:
            Button:
                text: "Go to Screen 2"
                on_press:
                  
                    root.manager.transition.direction = 'left'
                    root.manager.transition.duration = 1
                    root.manager.current = 'screen_two'
    
    <ScreenTwo>:
        BoxLayout:
            Button:
                text: "Go to Screen 1"
                on_press:
                    root.manager.transition.direction = 'right'
                    root.manager.current = 'screen_one'
    """)
    
    
    
    class ScreenOne(Screen):
        pass
    
    
    class ScreenTwo(Screen):
        pass
    


screen_manager = ScreenManager()


screen_manager.add_widget(ScreenOne(name="screen_one"))
screen_manager.add_widget(ScreenTwo(name="screen_two"))


class KivyTut2App(App):

    def build(self):
        return screen_manager


sample_app = KivyTut2App()
sample_app.run()
...