Kivy Course #9 – Multiple Screens in Kivy With ScreenManager [Part 2]

In this example, we improved and reviewed the code we have written in the previous post. Screen, ScreenManager and Builder are also used in this example, too. The code is:

#-*-coding:utf-8-*-

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

Builder.load_string("""
<GirisEkrani@Screen>:
    Button:
        text: "İleri"
        on_release: root.manager.current = root.manager.next()
<KontrolEkrani@Screen>:
    Button:
        text: "Geri"
        on_release: root.manager.current = root.manager.previous()
<RootWidget>:
    GirisEkrani:
        name: "ekran1"
    KontrolEkrani:
        name: "ekran2"
""")


class RootWidget(ScreenManager):
    pass

class ekranApp(App):
    def build(self):
        return RootWidget()

if __name__ == "__main__":
    ekranApp().run()

 

 
comments powered by Disqus