How Do You Change The Screen Transition Direction In Kivy, Within The Python Code?
I know how to change the transition direction in Kivy code form. Example: Button: text: 'Home' size_hint: 0.8, 0.2 on_release: root.manager.transition.directi
Solution 1:
Here's the example how your app should look like "just for switching screens".
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen, SlideTransition
classFirstPage(FloatLayout):
defswitch_screen(self):
myapp.screen_manager.transition = SlideTransition(direction='left', duration=.25)
myapp.screen_manager.current = 'SecondPage'classSecondPage(FloatLayout):
defswitch_back(self):
myapp.screen_manager.transition = SlideTransition(direction='right', duration=.25)
myapp.screen_manager.current = 'FirstPage'classMyApp(MDApp):
defbuild(self):
self.screen_manager = ScreenManager()
self.firstpage = FirstPage()
screen = Screen(name='FirstPage')
screen.add_widget(self.firstpage)
self.screen_manager.add_widget(screen)
self.secondpage = SecondPage()
screen = Screen(name='SecondPage')
screen.add_widget(self.secondpage)
self.screen_manager.add_widget(screen)
return self.screen_manager
myapp = MyApp()
myapp.run()
kivy
code:
FirstPage:<FirstPage>:Button:text:"First"on_release:root.switch_screen()<SecondPage>:Button:text:"Second"on_release:root.switch_back()
Post a Comment for "How Do You Change The Screen Transition Direction In Kivy, Within The Python Code?"