簡述
根據官方解釋:
No transition, instantly switches to the next screen with no delay or animation.
意思是NoTransition會立即切換到下一個Screen,沒有延遲或動畫。
基本範例
在main.py中寫上此段程式碼:
from kivy.app import App from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition from kivy.properties import ObjectProperty class AScreen(Screen): pass class BScreen(Screen): pass class sm(ScreenManager): a1 = ObjectProperty(NoTransition(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:
執行結果如下:
NoTransition使用技巧:
沒有~
沒有留言:
張貼留言