Skip to content

Commit b501499

Browse files
TinyuZhaolbuque
authored andcommitted
libs/m5ui: Add LVGL Menu widget docs and example.
Signed-off-by: tinyu <[email protected]>
1 parent 817d579 commit b501499

File tree

7 files changed

+642
-0
lines changed

7 files changed

+642
-0
lines changed

docs/en/m5ui/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Classes
7373
led.rst
7474
line.rst
7575
list.rst
76+
menu.rst
7677
msgbox.rst
7778
roller.rst
7879
scale.rst

docs/en/m5ui/menu.rst

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
.. currentmodule:: m5ui
2+
3+
M5Menu
4+
========
5+
6+
.. include:: ../refs/m5ui.menu.ref
7+
8+
M5Menu is a widget that can be used to create multi-level menus in the user interface.
9+
10+
UiFlow2 Example
11+
---------------
12+
13+
menu event
14+
^^^^^^^^^^^^^^
15+
16+
Open the |menu_core2_example.m5f2| project in UiFlow2.
17+
18+
This example creates a multi-level menus.
19+
20+
UiFlow2 Code Block:
21+
22+
|menu_core2_example.png|
23+
24+
Example output:
25+
26+
None
27+
28+
MicroPython Example
29+
-------------------
30+
31+
menu event
32+
^^^^^^^^^^^^^^
33+
34+
This example creates a multi-level menus.
35+
36+
MicroPython Code Block:
37+
38+
.. literalinclude:: ../../../examples/m5ui/menu/menu_core2_example.py
39+
:language: python
40+
:linenos:
41+
42+
Example output:
43+
44+
None
45+
46+
47+
**API**
48+
-------
49+
M5Menu
50+
^^^^^^^^
51+
52+
.. autoclass:: m5ui.menu.M5Menu
53+
:members:
54+
55+
.. py:method:: set_page(page)
56+
57+
Set main page for the menu.
58+
59+
:param lv.obj page: The main page object.
60+
61+
UiFlow2 Code Block:
62+
63+
|set_page.png|
64+
65+
MicroPython Code Block:
66+
67+
.. code-block:: python
68+
69+
menu0.set_page(menu0.main_page)
70+
71+
.. py:method:: set_mode_header(mode)
72+
73+
Set the mode header for the menu.
74+
75+
:param int mode: The mode header text.
76+
77+
Options:
78+
79+
- ``lv.menu.HEADER.TOP_FIXED``
80+
- ``lv.menu.HEADER.TOP_UNFIXED``
81+
- ``lv.menu.HEADER.BOTTOM_FIXED``
82+
83+
UiFlow2 Code Block:
84+
85+
|set_mode_header.png|
86+
87+
MicroPython Code Block:
88+
89+
.. code-block:: python
90+
91+
menu0.set_mode_header(lv.menu.HEADER.TOP_FIXED)
92+
93+
.. py:method:: set_pos(x, y)
94+
95+
Set the position of the menu.
96+
97+
:param int x: The x-coordinate of the menu.
98+
:param int y: The y-coordinate of the menu.
99+
100+
UiFlow2 Code Block:
101+
102+
|set_pos.png|
103+
104+
MicroPython Code Block:
105+
106+
.. code-block:: python
107+
108+
menu0.set_pos(100, 100)
109+
110+
.. py:method:: set_size(width, height)
111+
112+
Set the size of the menu.
113+
114+
:param int width: The width of the menu.
115+
:param int height: The height of the menu.
116+
117+
UiFlow2 Code Block:
118+
119+
|set_size.png|
120+
121+
MicroPython Code Block:
122+
123+
.. code-block:: python
124+
125+
menu0.set_size(100, 50)

docs/en/m5ui/switch.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: m5ui
2+
.. _m5ui.M5Switch:
23

34
M5Switch
45
========

docs/en/refs/m5ui.menu.ref

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. |set_page.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/set_page.png
2+
.. |set_mode_header.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/set_mode_header.png
3+
.. |set_pos.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/set_pos.png
4+
.. |set_size.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/set_size.png
5+
.. |add_label.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/add_label.png
6+
.. |add_label2.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/add_label2.png
7+
.. |add_switch.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/add_switch.png
8+
.. |add_switch2.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/add_switch2.png
9+
10+
11+
.. |menu_core2_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/m5ui/menu/example.png
12+
13+
.. |menu_core2_example.m5f2| raw:: html
14+
15+
<a
16+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/m5ui/menu/menu_core2_example.m5f2"
17+
target="_blank"
18+
>
19+
menu_core2_example.m5f2
20+
</a>

0 commit comments

Comments
 (0)