QNodeEditor.entries.combo_box.ComboBoxEntry#

class QNodeEditor.entries.combo_box.ComboBoxEntry(*args, items: ~typing.Iterable[str] = None, theme: ~typing.Type[~QNodeEditor.themes.theme.Theme] = <class 'QNodeEditor.themes.dark.DarkTheme'>, **kwargs)#

Bases: Entry

Entry housing a combo box with a set of items and a name.

The combo box menu is forced to be displayed on top of other items. The bottom of the drop-down menu shows the name of the combo box.

Examples

Example usage:

entry = ComboBoxEntry('Some entry', ['Option 1', 'Option 2', 'Option 3'])

node = MyNode()
node.add_entry(entry)

The Node class also contains helper methods to create combo box entries:

node = MyNode()

node.add_combo_box_entry('Some entry', {'Option 1': 10, 'Option 2': 5, 'Option 3': 15})

Note that combo box entries can only be static.

Properties

Methods

__init__

Create a new combo box entry.

load

Load the current combo box index from an entry state

save

Save the current index of the combo box in the entry state

set_z_order

Change the z-value of the combo box popup to ensure it is drawn on top..

__init__(*args, items: ~typing.Iterable[str] = None, theme: ~typing.Type[~QNodeEditor.themes.theme.Theme] = <class 'QNodeEditor.themes.dark.DarkTheme'>, **kwargs)#

Create a new combo box entry.

Parameters:
  • items (Iterable[str] or dict[str, Any]) –

    Items to add to the combo box.

    If items is an iterable of strings, they will be used as the names of the options, and the selected name is returned as the value of the combo box entry.

    If items is a dictionary, the keys will be used as the names of the options, and the values as the data associated with those options. The data associated to the selected option is then returned as the value of the combo box entry.

  • theme (Type[Theme], optional) – Theme for the entry (default: DarkTheme)

load(state: dict) bool#

Load the current combo box index from an entry state

Parameters:

state (dict) – Entry state

Returns:

Whether setting state succeeded

Return type:

bool

save() dict#

Save the current index of the combo box in the entry state

Returns:

State of the combo box

Return type:

dict

set_z_order(popup_visible: bool) None#

Change the z-value of the combo box popup to ensure it is drawn on top..

Parameters:

popup_visible (bool) – Whether the popup is visible

Return type:

None