#menu.py
from kivy.app import App
from kivy.uix.widget import Widget
class Menu(Widget):
def toggle1(self, widget):
widget.background_color = [0, 1, 1, 1]
self.ids["button2"].background_color = [1, 1, 1, 1]
self.ids["button3"].background_color = [1, 1, 1, 1]
self.ids["screen_manager"].current = "window1"
def toggle2(self, widget):
widget.background_color = [0, 1, 1, 1]
self.ids["button1"].background_color = [1, 1, 1, 1]
self.ids["button3"].background_color = [1, 1, 1, 1]
self.ids["screen_manager"].current = "window2"
def toggle3(self, widget):
widget.background_color = [0, 1, 1, 1]
self.ids["button1"].background_color = [1, 1, 1, 1]
self.ids["button2"].background_color = [1, 1, 1, 1]
self.ids["screen_manager"].current = "window3"
class MenuApp(App):
pass
MenuApp().run()
-----------------------------
#menu.kv
Menu:
BoxLayout:
size: root.width, root.height
orientation: "vertical"
BoxLayout:
size_hint: 1, 0.2
Button:
id: button1
text: "1"
on_press: root.toggle1(self)
Button:
id: button2
text: "2"
on_press: root.toggle2(self)
Button:
id: button3
text: "3"
on_press: root.toggle3(self)
ScreenManager:
id: screen_manager
Window1:
Window2:
Window3:
<Window1@Screen>:
name: "window1"
Label:
text: "window 1"
font_size: "150dp"
<Window2@Screen>:
name: "window2"
Label:
text: "window 2"
font_size: "150dp"
<Window3@Screen>:
name: "window3"
Label:
text: "window 3"
font_size: "150dp"
No comments:
Post a Comment