msl.qt.widgets.combobox module

A QComboBox with more options in the constructor.

class msl.qt.widgets.combobox.ComboBox(*, items=None, initial=None, index_changed=None, text_changed=None, tooltip=None, parent=None)[source]

Bases: QComboBox

A QComboBox with more options in the constructor.

Parameters
  • items (str, list of str, dict, optional) – The item(s) to add to the combobox. If a str, then adds the single item. If a list, then adds all items. If a dict, then the keys are the text of each item and the values can either be a QIcon to use as the icon or any other type to use as the userData parameter. To specify both an icon and userData for an item the values can be of type tuple, e.g., (icon, userData).

  • initial (int or str, optional) – The index or text of the item to initially display. This value is set before the slots are registered.

  • index_changed – A callable function to use as a slot for the currentIndexChanged() signal.

  • text_changed – A callable function to use as a slot for the currentTextChanged() signal.

  • tooltip (str, optional) – The tooltip to display for the combobox.

  • parent (QtWidgets.QWidget, optional) – The parent widget.