Pemrograman Python Kivy dengan Pydroid - ScreenManager
#ini codingnya silakan di copy paste untuk mempermudah praktik
#Simpan sebagai main.py
import kivy
#Simpan sebagai main.py
import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
Builder.load_string("""
<Layar1>:
BoxLayout:
orientation: "vertical"
Label:
text: "Halo Saya Layar 2"
Button:
text: "Ke layar dua -->"
on_press:
root.manager.transition.direction = "left"
root.manager.transition.duration = "1"
root.manager.current = "secondScreen"
<Layar2>:
BoxLayout:
orientation: "vertical"
Label:
text: "Halo Saya Layar 2"
Button:
text: "<-- Ke Layar 1"
on_press:
root.manager.transition.direction = "right"
root.manager.transition.duration = "1"
root.manager.current = "firstScreen"
""")
class Layar1(Screen):
pass
class Layar2(Screen):
pass
screen_manager = ScreenManager()
screen_manager.add_widget(Layar1(name="firstScreen"))
screen_manager.add_widget(Layar2(name="secondScreen"))
class myKebunApp(App):
def build(self):
return screen_manager
kucing = myKebunApp()
kucing.run()
Comments
Post a Comment