Skip to content

Commit 5a173d3

Browse files
committed
libs/label_plus.py: Fix timer exception issue.
Signed-off-by: lbuque <[email protected]>
1 parent 4a684d7 commit 5a173d3

File tree

9 files changed

+723
-24
lines changed

9 files changed

+723
-24
lines changed

docs/en/refs/widgets.label+.ref

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. |cores3_labelplus_example.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/cores3_labelplus_example.png
2+
.. |get_data.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/get_data.png
3+
.. |is_valid_data.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/is_valid_data.png
4+
.. |setColor.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/setColor.png
5+
.. |setCursor.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/setCursor.png
6+
.. |setFont.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/setFont.png
7+
.. |setSize.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/setSize.png
8+
.. |setText.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/setText.png
9+
.. |setVisible.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/setVisible.png
10+
.. |set_update_enable.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/set_update_enable.png
11+
.. |set_update_period.png| image:: https://static-cdn.m5stack.com/mpy_docs/widgets/label_plus/set_update_period.png
12+
13+
.. |cores3_labelplus_example.m5f2| raw:: html
14+
15+
<a
16+
href="https://uiflow2.m5stack.com/?example=https://raw.githubusercontent.com/m5stack/uiflow-micropython/develop/examples/widgets/labelplus/cores3_labelplus_example.m5f2"
17+
target="_blank"
18+
>
19+
cores3_labelplus_example.m5f2
20+
</a>

docs/en/widgets/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ Classes
9191
image.rst
9292
image+.rst
9393
label.rst
94+
label+.rst

docs/en/widgets/label+.rst

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
.. currentmodule:: Widgets
2+
3+
class LabelPlus -- display remote text
4+
======================================
5+
6+
The `LabelPlus` class extends the `Widgets.Label` class to provide additional functionalities for handling text with dynamic updates.
7+
8+
Currently only accepts strings in json format, and extracts data through ``json_key``.
9+
10+
.. include:: ../refs/widgets.label+.ref
11+
12+
UiFlow2 Example
13+
---------------
14+
15+
Simple Usage
16+
^^^^^^^^^^^^
17+
18+
Open the |cores3_labelplus_example.m5f2| project in UiFlow2.
19+
20+
This example demonstrates how to create and manipulate a LabelPlus widget.
21+
22+
UiFlow2 Code Block:
23+
24+
|cores3_labelplus_example.png|
25+
26+
Example output:
27+
28+
None
29+
30+
31+
MicroPython Example
32+
-------------------
33+
34+
Simple Usage
35+
^^^^^^^^^^^^
36+
37+
This example demonstrates how to create and manipulate a LabelPlus widget.
38+
39+
MicroPython Code Block:
40+
41+
.. literalinclude:: ../../../examples/widgets/labelplus/cores3_labelplus_example.py
42+
43+
Example output:
44+
45+
None
46+
47+
48+
**API**
49+
-------
50+
51+
LabelPlus
52+
^^^^^^^^^
53+
54+
.. autoclass:: label_plus.LabelPlus
55+
:members:
56+
:member-order: bysource
57+
58+
.. py:method:: setText(text)
59+
60+
Set the text of the LabelPlus widget.
61+
62+
:param str text: The text to set on the label.
63+
64+
UiFlow2 Code Block:
65+
66+
|setText.png|
67+
68+
MicroPython Code Block:
69+
70+
.. code-block:: python
71+
72+
label_plus_0.setText("New Text")
73+
74+
.. py:method:: setCursor(x=0, y=0)
75+
76+
Sets the starting coordinates of the text cursor in the LabelPlus widget.
77+
78+
:param int x: The x-coordinate of the cursor.
79+
:param int y: The y-coordinate of the cursor.
80+
81+
UiFlow2 Code Block:
82+
83+
|setCursor.png|
84+
85+
MicroPython Code Block:
86+
87+
.. code-block:: python
88+
89+
label_plus_0.setCursor(10, 20)
90+
91+
.. py:method:: setSize(size)
92+
93+
Sets the font size of the text in the LabelPlus widget.
94+
95+
:param float size: The font size to set.
96+
97+
UiFlow2 Code Block:
98+
99+
|setSize.png|
100+
101+
MicroPython Code Block:
102+
103+
.. code-block:: python
104+
105+
label_plus_0.setSize(1.5)
106+
107+
.. py:method:: setFont(font)
108+
109+
Sets the font of the text in the LabelPlus widget.
110+
111+
:param str font: The font to set (e.g., Widgets.FONTS.DejaVu9).
112+
113+
UiFlow2 Code Block:
114+
115+
|setFont.png|
116+
117+
MicroPython Code Block:
118+
119+
.. code-block:: python
120+
121+
label_plus_0.setFont(Widgets.FONTS.DejaVu9)
122+
123+
.. py:method:: setVisible(visible)
124+
125+
Set the visible property of the LabelPlus widget.
126+
127+
:param bool visible: True to make the label visible, False to hide it.
128+
129+
UiFlow2 Code Block:
130+
131+
|setVisible.png|
132+
133+
MicroPython Code Block:
134+
135+
.. code-block:: python
136+
137+
label_plus_0.setVisible(True)

0 commit comments

Comments
 (0)