-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.py
66 lines (55 loc) · 1.7 KB
/
menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from kivymd.uix.list import OneLineAvatarIconListItem, MDList
from kivymd.theming import ThemableBehavior
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty
from kivy.lang import Builder
from kivy.app import App
Builder.load_string(
'''
<ItemWidget>:
theme_text_color: "Custom"
text_color: app.theme_cls.text_color
IconLeftWidget:
theme_text_color: "Custom"
text_color: root.text_color
icon: root.icon
<ContentDrawer>:
orientation: "vertical"
FloatLayout:
size_hint_y: None
height: "200dp"
BoxLayout:
id: box_image
x: root.x
pos_hint: {"top": 1}
FitImage:
source: "menu.png"
MDLabel:
text: "Header Text"
size_hint_y: None
height: self.texture_size[1]
x: root.x + 10
y: root.height - box_image.height + dp(10)
ScrollView:
ScrollList:
id: scroll_list
'''
)
class ScrollList(ThemableBehavior, MDList):
def set_item_selected(self, instance):
for item in self.children:
if item.text_color == self.theme_cls.primary_color:
item.text_color = self.theme_cls.text_color
break
instance.text_color = self.theme_cls.primary_color
class ItemWidget(OneLineAvatarIconListItem):
icon = StringProperty()
screen = StringProperty()
def on_release(self):
self.parent.set_item_selected(self)
app = App.get_running_app()
if self.screen:
app.root.ids.screen_manager.current = self.screen
app.root.ids.nav_drawer.set_state()
class ContentDrawer(BoxLayout):
pass