Skip to content

Commit adc484c

Browse files
AidadikHeaTTheatR
authored andcommitted
docs: expand module documentation
fix: close reported issues feat: add new widgets and extend functionality of existing ones
1 parent a4247eb commit adc484c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+10465
-3887
lines changed

docs/sources/getting-started.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ First KivyMD application
4747
4848
MainApp().run()
4949
50-
.. rubric:: And the equivalent with `Kivy`:
50+
And the equivalent with `Kivy`
51+
-----------------------------
5152

5253
.. code-block:: python
5354
@@ -62,7 +63,8 @@ First KivyMD application
6263
6364
MainApp().run()
6465
65-
.. rubric:: To left - `Kivy`, to right - `KivyMD`:
66+
To left - `Kivy`, to right - `KivyMD`
67+
------------------------------------
6668

6769
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/hello-world.png
6870
:align: center
@@ -142,7 +144,8 @@ create a custom button in `Kivy`:
142144
143145
MainApp().run()
144146
145-
.. rubric:: And the equivalent with `KivyMD`:
147+
And the equivalent with `KivyMD`
148+
--------------------------------
146149

147150
.. code-block:: python
148151
@@ -170,12 +173,14 @@ create a custom button in `Kivy`:
170173
171174
MainApp().run()
172175
173-
.. rubric:: `KivyMD`:
176+
`KivyMD`
177+
--------
174178

175179
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/kivymd-ripple-rectangle-button.gif
176180
:align: center
177181

178-
.. rubric:: `Kivy`:
182+
`Kivy`
183+
------
179184

180185
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/kivy-ripple-rectangle-button.gif
181186
:align: center

kivymd/app.py

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,66 @@
77
library (like :attr:`~MDApp.theme_cls`). You can turn on the monitor
88
displaying the current `FP` value in your application:
99
10-
.. code-block:: python
10+
.. tabs::
1111
12-
KV = '''
13-
MDScreen:
14-
md_bg_color: self.theme_cls.backgroundColor
12+
.. tab:: Imperative python style with KV
1513
16-
MDLabel:
17-
text: "Hello, World!"
18-
halign: "center"
19-
'''
14+
.. code-block:: python
2015
21-
from kivy.lang import Builder
16+
KV = '''
17+
MDScreen:
18+
md_bg_color: self.theme_cls.backgroundColor
2219
23-
from kivymd.app import MDApp
20+
MDLabel:
21+
text: "Hello, World!"
22+
halign: "center"
23+
'''
2424
25+
from kivy.lang import Builder
2526
26-
class MainApp(MDApp):
27-
def build(self):
28-
return Builder.load_string(KV)
27+
from kivymd.app import MDApp
2928
30-
def on_start(self):
31-
self.fps_monitor_start()
3229
30+
class MainApp(MDApp):
31+
def build(self):
32+
return Builder.load_string(KV)
3333
34-
MainApp().run()
34+
def on_start(self):
35+
self.fps_monitor_start()
3536
36-
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/fps-monitor-dark.png
37-
:width: 350 px
38-
:align: center
3937
40-
.. note::
38+
MainApp().run()
4139
42-
Note that if you override the built-in on_start method, you will
43-
definitely need to call the super method:
40+
.. tab:: Declarative python style
4441
45-
.. code-block:: python
42+
.. code-block:: python
43+
44+
from kivymd.uix.label import MDLabel
45+
from kivymd.uix.screen import MDScreen
46+
from kivymd.app import MDApp
4647
47-
class MainApp(MDApp):
48-
def build(self):
49-
[...]
5048
51-
def on_start(self):
52-
[...]
49+
class MainApp(MDApp):
50+
def build(self):
51+
return (
52+
MDScreen(
53+
MDLabel(
54+
text="Hello, World!",
55+
halign="center",
56+
),
57+
md_bg_color=self.theme_cls.backgroundColor,
58+
)
59+
)
60+
61+
def on_start(self):
62+
self.fps_monitor_start()
63+
64+
65+
MainApp().run()
66+
67+
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/fps-monitor-dark.png
68+
:width: 350 px
69+
:align: center
5370
"""
5471

5572
__all__ = ("MDApp",)

kivymd/dynamic_color.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,11 @@ def theme_switch(self) -> None:
153153
154154
def generate_cards(self, *args):
155155
self.root.ids.card_list.data = []
156-
for color in self.theme_cls.schemes_name_colors:
157-
value = f"{color}Color"
156+
for color in self.theme_cls.dynamic_color_names:
158157
self.root.ids.card_list.data.append(
159158
{
160-
"bg_color": getattr(self.theme_cls, value),
161-
"text": value,
159+
"bg_color": getattr(self.theme_cls, color),
160+
"text": color,
162161
}
163162
)
164163
@@ -256,12 +255,11 @@ def theme_switch(self) -> None:
256255
257256
def generate_cards(self, *args):
258257
self.root.ids.card_list.data = []
259-
for color in self.theme_cls.schemes_name_colors:
260-
value = f"{color}Color"
258+
for color in self.theme_cls.dynamic_color_names:
261259
self.root.ids.card_list.data.append(
262260
{
263-
"bg_color": getattr(self.theme_cls, value),
264-
"text": value,
261+
"bg_color": getattr(self.theme_cls, color),
262+
"text": color,
265263
}
266264
)
267265

kivymd/factory_registers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
register("MDLabel", module="kivymd.uix.label")
7474
register("MDIcon", module="kivymd.uix.label")
7575
register("MDBadge", module="kivymd.uix.badge")
76+
register("MDLoadingIndicator", module="kivymd.uix.loadingindicator")
7677
register("MDList", module="kivymd.uix.list")
7778
register("MDListItem", module="kivymd.uix.list")
7879
register("MDListItemHeadlineText", module="kivymd.uix.list")
@@ -83,7 +84,7 @@
8384
register("MDListItemTrailingCheckbox", module="kivymd.uix.list")
8485
register("MDListItemTertiaryText", module="kivymd.uix.list")
8586
register("HoverBehavior", module="kivymd.uix.behaviors.hover_behavior")
86-
register("FocusBehavior", module="kivymd.uix.behaviors.focus_behavior")
87+
register("StateFocusBehavior", module="kivymd.uix.behaviors.focus_behavior")
8788
register("MagicBehavior", module="kivymd.uix.behaviors.magic_behavior")
8889
register("MDNavigationDrawer", module="kivymd.uix.navigationdrawer")
8990
register("MDNavigationLayout", module="kivymd.uix.navigationdrawer")

kivymd/font_definitions.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,120 @@
55
.. seealso::
66
77
`Material Design spec, The type system <https://material.io/design/typography/the-type-system.html>`_
8+
9+
Example
10+
=======
11+
12+
.. tabs::
13+
14+
.. tab:: Imperative python style with KV
15+
16+
.. code-block:: python
17+
18+
from kivy.lang import Builder
19+
20+
from kivymd.font_definitions import theme_font_styles
21+
from kivymd.app import MDApp
22+
23+
KV = '''
24+
MDScreen:
25+
md_bg_color: self.theme_cls.backgroundColor
26+
27+
MDRecycleView:
28+
id: rv
29+
key_viewclass: 'viewclass'
30+
key_size: 'height'
31+
32+
RecycleBoxLayout:
33+
padding: dp(10)
34+
spacing: dp(10)
35+
default_size: None, dp(48)
36+
default_size_hint: 1, None
37+
size_hint_y: None
38+
height: self.minimum_height
39+
orientation: "vertical"
40+
'''
41+
42+
43+
class Example(MDApp):
44+
def build(self):
45+
self.theme_cls.theme_style = "Dark"
46+
return Builder.load_string(KV)
47+
48+
def on_start(self):
49+
for style in theme_font_styles:
50+
if style != "Icon":
51+
for role in theme_font_styles[style]:
52+
font_size = int(theme_font_styles[style][role]["font-size"])
53+
self.root.ids.rv.data.append(
54+
{
55+
"viewclass": "MDLabel",
56+
"text": f"{style} {role} {font_size} sp",
57+
"adaptive_height": "True",
58+
"font_style": style,
59+
"role": role,
60+
}
61+
)
62+
63+
64+
Example().run()
65+
66+
.. tab:: Declarative python style
67+
68+
.. code-block:: python
69+
70+
from kivymd.material_resources import dp
71+
from kivymd.uix.recycleboxlayout import MDRecycleBoxLayout
72+
from kivymd.uix.recycleview import MDRecycleView
73+
from kivymd.uix.screen import MDScreen
74+
from kivymd.app import MDApp
75+
from kivymd.font_definitions import theme_font_styles
76+
77+
78+
class Example(MDApp):
79+
def build(self):
80+
self.theme_cls.theme_style = "Dark"
81+
self.screen = (
82+
MDScreen(
83+
MDRecycleView(
84+
MDRecycleBoxLayout(
85+
padding=(dp(10), dp(10), 0, dp(10)),
86+
default_size=(None, dp(48)),
87+
default_size_hint=(1, None),
88+
size_hint_y=None,
89+
adaptive_height=True,
90+
orientation='vertical',
91+
),
92+
id="rv",
93+
),
94+
md_bg_color=self.theme_cls.backgroundColor,
95+
)
96+
)
97+
rv = self.screen.get_ids().rv
98+
rv.key_viewclass = 'viewclass'
99+
rv.key_size = 'height'
100+
return self.screen
101+
102+
def on_start(self):
103+
for style in theme_font_styles:
104+
if style != "Icon":
105+
for role in theme_font_styles[style]:
106+
font_size = int(theme_font_styles[style][role]["font-size"])
107+
self.screen.get_ids().rv.data.append(
108+
{
109+
"viewclass": "MDLabel",
110+
"text": f"{style} {role} {font_size} sp",
111+
"adaptive_height": "True",
112+
"font_style": style,
113+
"role": role,
114+
}
115+
)
116+
117+
118+
Example().run()
119+
120+
.. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/label-font-style-preview.png
121+
:align: center
8122
"""
9123

10124
from kivy.core.text import LabelBase

0 commit comments

Comments
 (0)