spino.gui_toolkit.widget.MyDropDown module¶
- class spino.gui_toolkit.widget.MyDropDown.MyDropdown(parent, row, column, options, label_text=None, color='#AAAAAA', initial_value=0, columnspan=2, **kwargs)[source]¶
Bases:
FrameA custom dropdown widget that wraps tkinter’s OptionMenu in a Frame.
This class creates a dropdown menu with customizable appearance and behavior, inheriting from Frame to provide better grid layout management and consistent styling. It can optionally include a label.
- Variables:
chosen_var (StringVar) – The variable that stores the selected option
dropdown (OptionMenu) – The underlying tkinter OptionMenu widget
- Parameters:
- __init__(parent, row, column, options, label_text=None, color='#AAAAAA', initial_value=0, columnspan=2, **kwargs)[source]¶
Initialize the MyDropdown widget.
- Parameters:
parent (
Any) – The parent widgetrow (
int) – Row position in the parent’s gridcolumn (
int) – Column position in the parent’s gridoptions (
Optional[List[str]]) – List of options to display in the dropdownlabel_text (
Optional[str]) – Optional text to display as a label before the dropdowncolor (
str) – Background color of the containing frameinitial_value (
int) – Index of the initially selected optioncolumnspan (
int) – Number of columns the widget should span**kwargs (
Dict[str,Any]) – Additional keyword arguments passed to the Frame widget
- Return type:
None
- get_value()[source]¶
Get the currently selected value from the dropdown.
- Returns:
The currently selected option
- Return type:
- set_callback(callback_function)[source]¶
Set a callback function that triggers when the dropdown value changes.
- Parameters:
callback_function – Function to call when selection changes
- Return type: