choiceseditor

class camelot.view.controls.editors.choiceseditor.ChoicesEditor(parent=None, nullable=True, field_name='choices', actions=[], **kwargs)[source]

A ComboBox aka Drop Down box that can be assigned a list of keys and values

static append_item(model, data)[source]

Append an item in a combobox model :param data: a dictionary mapping roles to values

get_choices()[source]
Return type:a list of (value,name) tuples
get_value()[source]

Get the current value of the combobox

set_choices(choices)[source]
Parameters:choices – a list of (value,name) tuples or a list of dicts.

In case a list of tuples is used, name will be displayed in the combobox, while value will be used within get_value() and set_value().

In case a list of dicts is used, the keys of the dict are used as the roles, and the values as the value for that role, where Qt.UserRole is the value that is passed through get_value(), eg : {Qt.DisplayRole: “Hello”, Qt.UserRole: 1}

This method changes the items in the combo box while preserving the current value, even if this value is not in the new list of choices. If there is no item with value None in the list of choices, this will be added.

set_value(value, display_role=None)[source]

Set the current value of the combobox where value, the name displayed is the one that matches the value in the list set with set_choices

Parameters:display_role – this is the name used to display the value in case the value is not in the list of choices. If this is None, the string representation of the value is used.