class documentation
A simple toggle switch for the GUI.
| Method | __del__ |
Clean up resources and deinitialize LVGL. |
| Method | __init__ |
Initialize the Toggle switch with drawing context and styling. |
| Method | clear |
Clear the toggle area with the background color. |
| Method | draw |
Render the toggle switch on the display. |
| Method | state |
Set the toggle state and redraw. |
| Method | text |
Set the toggle text and redraw. |
| Method | toggle |
Toggle the current state. |
| Method | update |
Update both text and state of the toggle. |
| Instance Variable | background |
Undocumented |
| Instance Variable | border |
Undocumented |
| Instance Variable | border |
Undocumented |
| Instance Variable | display |
Undocumented |
| Instance Variable | foreground |
Undocumented |
| Instance Variable | is |
Undocumented |
| Instance Variable | on |
Undocumented |
| Instance Variable | position |
Undocumented |
| Instance Variable | size |
Undocumented |
| Instance Variable | use |
Undocumented |
| Property | state |
Get the current state of the toggle. |
| Property | text |
Get the current text of the toggle. |
| Instance Variable | _lvgl |
Undocumented |
| Instance Variable | _state |
Undocumented |
| Instance Variable | _text |
Undocumented |
def __init__(self, draw, position:
Vector, size: Vector, text: str, initial_state: bool = False, foreground_color: int = 65535, background_color: int = 0, on_color: int = 31, border_color: int = 65535, border_width: int = 1, should_clear: bool = True, use_lvgl: bool = True):
¶
Initialize the Toggle switch with drawing context and styling.
| Parameters | |
draw:Draw | The drawing context to render the toggle. |
position:Vector | Vector position of the toggle. |
size:Vector | Vector size of the toggle. |
text:str | The label text for the toggle. |
initialbool | Initial state of the toggle. Defaults to False. |
foregroundint | The color of the text. Defaults to 0xFFFF. |
backgroundint | The background color. Defaults to 0x0000. |
onint | The color when the toggle is on. Defaults to 0x001F. |
borderint | The color of the border. Defaults to 0xFFFF. |
borderint | The width of the border. Defaults to 1. |
shouldbool | Whether to clear on init. Defaults to True. |
usebool | Whether to use LVGL rendering. Defaults to True. |
Render the toggle switch on the display.
| Parameters | |
swap:bool | Whether to swap the display buffer. Defaults to True. |
clear:bool | Whether to clear the area first. Defaults to True. |
selected:bool | Whether the toggle is selected. Defaults to False. |