class documentation
class ToggleList:
Constructor: ToggleList(view_manager, foreground_color, background_color, on_color, ...)
A class to manage a list of Toggle objects.
| Method | __del__ |
Clean up resources. |
| Method | __init__ |
Initialize the ToggleList with styling and an optional callback. |
| Method | add |
Add a new toggle to the list. |
| Method | clear |
Clear the toggle area with the background color. |
| Method | remove |
Remove a toggle from the list by index. |
| Method | run |
Handle input to navigate and toggle items in the list. |
| Method | update |
Update the text and state of a specific toggle in the list. |
| Instance Variable | background |
Undocumented |
| Instance Variable | border |
Undocumented |
| Instance Variable | border |
Undocumented |
| Instance Variable | foreground |
Undocumented |
| Instance Variable | max |
Undocumented |
| Instance Variable | on |
Undocumented |
| Instance Variable | position |
Undocumented |
| Instance Variable | size |
Undocumented |
| Instance Variable | states |
Undocumented |
| Instance Variable | toggle |
Undocumented |
| Instance Variable | toggle |
Undocumented |
| Instance Variable | toggle |
Undocumented |
| Instance Variable | toggle |
Undocumented |
| Instance Variable | view |
Undocumented |
| Property | current |
Get the currently selected item (Toggle). |
| Property | current |
Get the state of the currently selected toggle. |
| Property | current |
Get the text of the currently selected toggle. |
| Property | item |
Get the number of items in the list. |
| Property | list |
Get the height of the list. |
| Property | selected |
Get the selected index. |
| Method | __draw |
Render up to 8 toggles at a time with scrolling. |
| Method | __scroll |
Scroll down the toggle list. |
| Method | __scroll |
Scroll the list up by one item. |
| Method | __toggle |
Toggle the state of the currently selected item. |
| Instance Variable | _callback |
Undocumented |
| Instance Variable | _just |
Undocumented |
| Instance Variable | _selected |
Undocumented |
def __init__(self, view_manager, foreground_color:
int = 65535, background_color: int = 0, on_color: int = 31, border_color: int = 65535, border_width: int = 1, callback: callable = None):
¶
Initialize the ToggleList with styling and an optional callback.
| Parameters | |
viewViewManager | The view manager to render and handle input. |
foregroundint | The color of the text. Defaults to 0xFFFF. |
backgroundint | The background color. Defaults to 0x0000. |
onint | The color when a toggle is on. Defaults to 0x001F. |
borderint | The color of the border. Defaults to 0xFFFF. |
borderint | The width of the border. Defaults to 1. |
callback:callable | Optional callback called when a toggle changes. Defaults to None. |
Add a new toggle to the list.
| Parameters | |
text:str | The label text for the toggle. |
initialbool | Initial state of the toggle. Defaults to False. |
Remove a toggle from the list by index.
| Parameters | |
index:int | The index of the toggle to remove. |
| Returns | |
bool | True if removed, False otherwise. |