|
| 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