KivyMD ScreenManager
KivyMD screen manager is used to combine multiple screens in app.
- Import MDApp from kivymd.app
- import builder from kivy.lang
- Declare two screens in kv screen A & screen B
- Create one button in each screen by clicking on it it will switch to another screen.
from kivymd.app import MDApp
from kivy.lang import Builder
KV='''
MDScreenManager:
MDScreen:
name:"screen A"
md_bg_color: "lightblue"
MDRaisedButton:
text: "Move to Screen B"
pos_hint: {"center_x": .5,"center_y": .5}
y: "36dp"
on_press:root.current="screen B"
MDScreen:
name:"screen B"
md_bg_color: "cadetblue"
MDRaisedButton:
text: "Move to Screen A"
pos_hint: {"center_x": .5,"center_y": .5}
y: "36dp"
on_press:root.current="screen A"
'''
class Example(MDApp):
def build(self):
return Builder.load_string(KV)
Example().run()
Output:
when you click on button ‘Move to Screen A’ as shown above it will move to another screen as shown in slideshows.