class documentation

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_toggle Add a new toggle to the list.
Method clear Clear the toggle area with the background color.
Method remove_toggle Remove a toggle from the list by index.
Method run Handle input to navigate and toggle items in the list.
Method update_toggle Update the text and state of a specific toggle in the list.
Instance Variable background_color Undocumented
Instance Variable border_color Undocumented
Instance Variable border_width Undocumented
Instance Variable foreground_color Undocumented
Instance Variable max_visible_items Undocumented
Instance Variable on_color Undocumented
Instance Variable position Undocumented
Instance Variable size Undocumented
Instance Variable states Undocumented
Instance Variable toggle_list Undocumented
Instance Variable toggle_position Undocumented
Instance Variable toggle_size Undocumented
Instance Variable toggle_spacing Undocumented
Instance Variable view_manager Undocumented
Property current_item Get the currently selected item (Toggle).
Property current_state Get the state of the currently selected toggle.
Property current_text Get the text of the currently selected toggle.
Property item_count Get the number of items in the list.
Property list_height Get the height of the list.
Property selected_index Get the selected index.
Method __draw Render up to 8 toggles at a time with scrolling.
Method __scroll_down Scroll down the toggle list.
Method __scroll_up Scroll the list up by one item.
Method __toggle Toggle the state of the currently selected item.
Instance Variable _callback Undocumented
Instance Variable _just_started Undocumented
Instance Variable _selected_index Undocumented
def __del__(self):

Clean up resources.

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
view_manager:ViewManagerThe view manager to render and handle input.
foreground_color:intThe color of the text. Defaults to 0xFFFF.
background_color:intThe background color. Defaults to 0x0000.
on_color:intThe color when a toggle is on. Defaults to 0x001F.
border_color:intThe color of the border. Defaults to 0xFFFF.
border_width:intThe width of the border. Defaults to 1.
callback:callableOptional callback called when a toggle changes. Defaults to None.
def add_toggle(self, text: str, initial_state: bool = False):

Add a new toggle to the list.

Parameters
text:strThe label text for the toggle.
initial_state:boolInitial state of the toggle. Defaults to False.
def clear(self):

Clear the toggle area with the background color.

def remove_toggle(self, index: int) -> bool:

Remove a toggle from the list by index.

Parameters
index:intThe index of the toggle to remove.
Returns
boolTrue if removed, False otherwise.
def run(self) -> bool:

Handle input to navigate and toggle items in the list.

Returns
boolFalse if the user wants to exit.
def update_toggle(self, index: int, text: str, state: bool) -> bool:

Update the text and state of a specific toggle in the list.

Parameters
index:intThe index of the toggle to update.
text:strThe new toggle text.
state:boolThe new toggle state.
Returns
boolTrue if updated, False otherwise.
background_color =

Undocumented

border_color =

Undocumented

border_width =

Undocumented

foreground_color =

Undocumented

max_visible_items: int =

Undocumented

on_color =

Undocumented

position =

Undocumented

size =

Undocumented

states: list =

Undocumented

toggle_list: list =

Undocumented

toggle_position =

Undocumented

toggle_size =

Undocumented

toggle_spacing =

Undocumented

view_manager =

Undocumented

@property
current_item =

Get the currently selected item (Toggle).

@property
current_state: bool =

Get the state of the currently selected toggle.

@property
current_text: str =

Get the text of the currently selected toggle.

@property
item_count: int =

Get the number of items in the list.

@property
list_height: int =

Get the height of the list.

@property
selected_index: int =

Get the selected index.

def __draw(self):

Render up to 8 toggles at a time with scrolling.

def __scroll_down(self):

Scroll down the toggle list.

def __scroll_up(self):

Scroll the list up by one item.

def __toggle(self):

Toggle the state of the currently selected item.

_callback =

Undocumented

_just_started: bool =

Undocumented

_selected_index =

Undocumented