Chapter 1: Getting started with kivy



Download 0,86 Mb.
Pdf ko'rish
bet14/15
Sana01.01.2022
Hajmi0,86 Mb.
#285987
1   ...   7   8   9   10   11   12   13   14   15
Bog'liq
kivy

Screen Manager

In the following example there are 2 Screens: SettingsScreen and MenuScreen

Using the first button, on the current screen will change your screen to the other screen.

Here is the code:

from kivy.app import App 

from kivy.lang import Builder 

from kivy.uix.screenmanager import ScreenManager, Screen 

 

# Create both screens. Please note the root.manager.current: this is how 



# you can control the ScreenManager from kv. Each screen has by default a 

# property manager that gives you the instance of the ScreenManager used. 

Builder.load_string(""" 

    BoxLayout: 

        Button: 

            text: 'First Button on Menu' 

            on_press: root.manager.current = 'settings' 

        Button: 

            text: 'Second Button on Menu' 

 

    BoxLayout: 

        Button: 

            text: 'First Button on Settings' 

            on_press: root.manager.current = 'menu' 

        Button: 

            text: 'Second Button on Settings' 

 

""") 


 

# Declare both screens 

class MenuScreen(Screen): 

    pass 

 

class SettingsScreen(Screen): 



    pass 

 

# Create the screen manager 



sm = ScreenManager() 

sm.add_widget(MenuScreen(name='menu')) 

sm.add_widget(SettingsScreen(name='settings')) 

 

https://riptutorial.com/



18


 

class TestApp(App): 

 

    def build(self): 



        return sm 

 

if __name__ == '__main__': 



    TestApp().run()

Read Using the Screen Manager online: 

https://riptutorial.com/kivy/topic/6097/using-the-screen-

manager


https://riptutorial.com/

19




Download 0,86 Mb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish