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: Frame

A 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 widget

  • row (int) – Row position in the parent’s grid

  • column (int) – Column position in the parent’s grid

  • options (Optional[List[str]]) – List of options to display in the dropdown

  • label_text (Optional[str]) – Optional text to display as a label before the dropdown

  • color (str) – Background color of the containing frame

  • initial_value (int) – Index of the initially selected option

  • columnspan (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:

str

set_value(value)[source]

Set the selected value of the dropdown.

Parameters:

value (str) – The option to select

Return type:

None

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:

None

clean_widget()[source]

Remove the widget from the display by clearing both grid and place geometry managers.

Return type:

None

set_status(status)[source]

Enable or disable the dropdown.

Parameters:

status – The state to set the dropdown to (‘normal’, ‘disabled’, etc.)

Return type:

None