簡述
根據官方解釋:
Transition where the new screen rises from the screen centre, becoming larger and changing from transparent to opaque until it fills the screen. Mimics the popular/standard Android transition.
基本範例
在main.py中寫上此段程式碼:
from kivy.app import App from kivy.uix.screenmanager import ScreenManager, Screen, RiseInTransition from kivy.properties import ObjectProperty class AScreen(Screen): pass class BScreen(Screen): pass class sm(ScreenManager): a1 = ObjectProperty(RiseInTransition(duration=3)) class MyApp(App): def build(self): return sm() if __name__ == '__main__': MyApp().run()
在my.kv中寫上此段程式碼:
<AScreen>: name: 'menu' BoxLayout: Button: text: 'Goto settings' on_press: root.manager.current = 'settings' Label: text: str(root.transition_progress) <BScreen>: name: 'settings' BoxLayout: Label: text: str(root.transition_progress) Button: text: 'still settings' on_press: root.manager.current = 'menu' <sm>: transition: root.a1 AScreen: BScreen:
執行結果如下:
RiseInTransition使用技巧:
沒有
沒有留言:
張貼留言