GUIBRUSHR.GUI.WIDGET.MyDropDown module

class GUIBRUSHR.GUI.WIDGET.MyDropDown.MyDropdown(parent: Any, row: int, column: int, options: List[str] | None, label_text: str | None = None, color: str = '#AAAAAA', initial_value: int = 0, columnspan: int = 2, **kwargs: Dict[str, Any])[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.

chosen_var

The variable that stores the selected option

Type:

StringVar

dropdown

The underlying tkinter OptionMenu widget

Type:

OptionMenu

__init__(parent: Any, row: int, column: int, options: List[str] | None, label_text: str | None = None, color: str = '#AAAAAA', initial_value: int = 0, columnspan: int = 2, **kwargs: Dict[str, Any]) None[source]

Initialize the MyDropdown widget.

Parameters:
  • parent – The parent widget

  • row – Row position in the parent’s grid

  • column – Column position in the parent’s grid

  • options – List of options to display in the dropdown

  • label_text – Optional text to display as a label before the dropdown

  • color – Background color of the containing frame

  • initial_value – Index of the initially selected option

  • columnspan – Number of columns the widget should span

  • **kwargs – Additional keyword arguments passed to the Frame widget

get_value() str[source]

Get the currently selected value from the dropdown.

Returns:

The currently selected option

Return type:

str

set_value(value: str) None[source]

Set the selected value of the dropdown.

Parameters:

value – The option to select

set_callback(callback_function) None[source]

Set a callback function that triggers when the dropdown value changes.

Parameters:

callback_function – Function to call when selection changes

clean_widget() None[source]

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

set_status(status) None[source]

Enable or disable the dropdown.

Parameters:

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