#screen2.py
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
class MainWindow(Screen):
pass
class SecondWindow(Screen):
pass
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("screen2.kv")
class Screen2App(App):
def build(self):
return kv
Screen2App().run()
-----------------------
#screen2.kv
WindowManager:
MainWindow:
SecondWindow:
<MainWindow>:
name: "main"
GridLayout:
size_hint: 1, 0.5
pos_hint: {"y": 0.25}
cols:1
GridLayout:
cols: 2
Label:
text: "Password: "
TextInput:
id: passw
multiline: False
padding : 6,self.height/2 - self.font_size/2,6,6
Button:
text: "submit"
on_release: app.root.current = "second" if passw.text == "password" else "main"
<SecondWindow>:
name: "second"
Button:
size_hint: 0.5, 0.5
pos_hint: {"x": 0.25, "y": 0.25}
text: "Go Back"
on_release: app.root.current = "main"
reference:
No comments:
Post a Comment