|
2 | 2 | import sys
|
3 | 3 |
|
4 | 4 | from kivy.core.window import Window
|
5 |
| -from kivy.metrics import dp |
6 |
| -from kivy.uix.boxlayout import BoxLayout |
7 |
| -from kivy.lang import Builder |
8 | 5 | from kivy import __version__ as kv__version__
|
9 |
| -from kivymd import __version__ |
| 6 | +from kivy.lang import Builder |
| 7 | +from kivy.metrics import dp |
| 8 | + |
10 | 9 | from kivymd.app import MDApp
|
| 10 | +from kivymd import __version__ |
| 11 | +from kivymd.uix.list import ( |
| 12 | + MDListItem, |
| 13 | + MDListItemHeadlineText, |
| 14 | + MDListItemSupportingText, |
| 15 | + MDListItemLeadingIcon, |
| 16 | +) |
| 17 | + |
11 | 18 | from materialyoucolor import __version__ as mc__version__
|
12 | 19 |
|
13 | 20 | from examples.common_app import CommonApp
|
14 | 21 |
|
15 | 22 | MAIN_KV = """
|
16 |
| -<Item>: |
17 |
| - size_hint_y: None |
18 |
| - height: "50dp" |
19 |
| - text: "" |
20 |
| - sub_text: "" |
21 |
| - icon: "" |
22 |
| - spacing: "5dp" |
23 |
| -
|
24 |
| - MDIcon: |
25 |
| - icon: root.icon |
26 |
| - size_hint: None, 1 |
27 |
| - width: self.height |
28 |
| -
|
29 |
| - BoxLayout: |
30 |
| - orientation: "vertical" |
31 |
| -
|
32 |
| - MDLabel: |
33 |
| - text: root.text |
34 |
| -
|
35 |
| - MDLabel: |
36 |
| - adaptive_height: True |
37 |
| - text: root.sub_text |
38 |
| - font_style: "Body" |
39 |
| - role: "medium" |
40 |
| - shorten: True |
41 |
| - shorten_from: "right" |
42 |
| - theme_text_color: "Custom" |
43 |
| - text_color: app.theme_cls.onSurfaceVariantColor[:-1] + [0.9] |
44 |
| -
|
45 | 23 | MDScreen:
|
46 | 24 | md_bg_color: app.theme_cls.backgroundColor
|
47 | 25 |
|
48 |
| - BoxLayout: |
49 |
| - orientation: "vertical" |
| 26 | + MDScrollView: |
| 27 | + do_scroll_x: False |
50 | 28 |
|
51 |
| - MDScrollView: |
52 |
| - do_scroll_x: False |
| 29 | + MDBoxLayout: |
| 30 | + id: main_scroll |
| 31 | + orientation: "vertical" |
| 32 | + adaptive_height: True |
53 | 33 |
|
54 | 34 | MDBoxLayout:
|
55 |
| - id: main_scroll |
56 |
| - spacing: "20dp" |
57 |
| - orientation: "vertical" |
58 |
| - adaptive_height: True |
59 |
| - padding: "10dp", 0 |
60 |
| -
|
61 |
| - MDBoxLayout: |
62 |
| - adaptive_height: True |
63 |
| -
|
64 |
| - MDLabel: |
65 |
| - theme_font_size: "Custom" |
66 |
| - text: "OS Info" |
67 |
| - font_size: "55sp" |
68 |
| - adaptive_height: True |
69 |
| - padding: "10dp", "20dp", 0, 0 |
70 |
| -
|
71 |
| - BoxLayout: |
72 |
| - orientation: "vertical" |
73 |
| - size_hint_x: None |
74 |
| - width: dp(70) |
75 |
| - padding: 0, "20dp", "10dp", 0 |
76 |
| -
|
77 |
| - MDIconButton: |
78 |
| - on_release: app.open_menu(self) |
79 |
| - size_hint: None, None |
80 |
| - size: [dp(50)] * 2 |
81 |
| - icon: "menu" |
82 |
| - pos_hint: {"center_x": .8, "center_y": .9} |
83 |
| -
|
84 |
| - Widget: |
| 35 | + adaptive_height: True |
| 36 | +
|
| 37 | + MDLabel: |
| 38 | + theme_font_size: "Custom" |
| 39 | + text: "OS Info" |
| 40 | + font_size: "55sp" |
| 41 | + adaptive_height: True |
| 42 | + padding: "10dp", "20dp", 0, 0 |
| 43 | +
|
| 44 | + MDIconButton: |
| 45 | + icon: "menu" |
| 46 | + on_release: app.open_menu(self) |
| 47 | + pos_hint: {"center_y": .5} |
85 | 48 | """
|
86 | 49 |
|
87 | 50 |
|
88 |
| -class Item(BoxLayout): |
89 |
| - pass |
90 |
| - |
91 |
| - |
92 | 51 | class Example(MDApp, CommonApp):
|
93 | 52 | def build(self):
|
94 | 53 | self.theme_cls.theme_style = "Dark"
|
@@ -124,11 +83,20 @@ def on_start(self):
|
124 | 83 | pass
|
125 | 84 |
|
126 | 85 | for info_item in info:
|
127 |
| - widget = Item() |
128 |
| - widget.text = info_item |
129 |
| - widget.sub_text = str(info[info_item][0]) |
130 |
| - widget.icon = info[info_item][1] |
131 |
| - self.root.ids.main_scroll.add_widget(widget) |
| 86 | + self.root.ids.main_scroll.add_widget( |
| 87 | + MDListItem( |
| 88 | + MDListItemLeadingIcon( |
| 89 | + icon=info[info_item][1], |
| 90 | + ), |
| 91 | + MDListItemHeadlineText( |
| 92 | + text=info_item, |
| 93 | + ), |
| 94 | + MDListItemSupportingText( |
| 95 | + text=str(info[info_item][0]), |
| 96 | + ), |
| 97 | + pos_hint={"center_x": .5, "center_y": .5}, |
| 98 | + ) |
| 99 | + ) |
132 | 100 |
|
133 | 101 | Window.size = [dp(350), dp(600)]
|
134 | 102 |
|
|
0 commit comments