OptionItem#
- name: str | None,
- text: str | None = None,
- default: bool = False,
- on_value_changed_fn: Callable[[bool], None] | None = None,
- model: SimpleBoolModel | None = None,
- setting_path: str | None = None,
- enabled: bool = True,
- checkable: bool = True,
- hide_on_click: bool = False,
Bases:
AbstractOptionItem
Represents a general item for OptionsMenu.
- Parameters:
name (str) – The name of the menu item.
text (str) – The text to display for the menu item. Defaults to the name if not provided.
default (bool) – The initial value of the item. Defaults to False.
on_value_changed_fn (Callable[[bool], None]) – A callback function that is called when the item’s value changes.
model (Optional[ui.SimpleBoolModel]) – The model associated with the item. If not provided, a new model is created.
setting_path (Optional[str]) – The path used to store the item’s setting. If not provided, no setting is stored.
enabled (bool) – Indicates whether the menu item is enabled. Defaults to True.
checkable (bool) – Determines if the menu item can be checked. Defaults to True.
hide_on_click (bool) – Determines if the menu item should hide when clicked. Defaults to False.
Methods
__init__
(name[, text, default, ...])Constructor for OptionItem.
build_custom_widget
(item)Builds a custom widget for the associated menu item.
build_menu_item
(**kwargs)Builds the associated menu item with the given keyword arguments.
destroy
()Cleans up any resources held by the item.
Executes the action associated with the item when it is triggered.
reset
()Resets the option item's value to its default state.
Attributes
Gets the dirty state indicating if the item's value has changed.
Gets the enabled state of the option item.
Gets the value model of the option item.
Gets the current value of the option item.
- name: str | None,
- text: str | None = None,
- default: bool = False,
- on_value_changed_fn: Callable[[bool], None] | None = None,
- model: SimpleBoolModel | None = None,
- setting_path: str | None = None,
- enabled: bool = True,
- checkable: bool = True,
- hide_on_click: bool = False,
Constructor for OptionItem.
Builds a custom widget for the associated menu item.
- Parameters:
item (ui.MenuItem) – The menu item associated with this option.
Builds the associated menu item with the given keyword arguments.
- Keyword Arguments:
enabled (bool) – If the menu item is enabled.
Cleans up any resources held by the item.
Executes the action associated with the item when it is triggered.
Resets the option item’s value to its default state.
Gets the dirty state indicating if the item’s value has changed.
- Returns:
The current dirty state.
- Return type:
bool
Gets the enabled state of the option item.
- Returns:
The current enabled state.
- Return type:
bool
Gets the value model of the option item.
- Returns:
The current value model.
- Return type:
ui.SimpleBoolModel
Gets the current value of the option item.
- Returns:
The current value.
- Return type:
bool