

def refresh_items(self):
    ' Refresh the items in the combo box.\n\n        '
    d = self.declaration
    selected = d.selected
    to_string = d.to_string
    to_icon = d.to_icon
    widget = self.widget
    self._guard |= SELECTED_GUARD
    try:
        widget.clear()
        target_index = (- 1)
        for (index, item) in enumerate(d.items):
            text = to_string(item)
            icon = to_icon(item)
            if (icon is None):
                qicon = None
            else:
                qicon = get_cached_qicon(icon)
            if (qicon is None):
                widget.addItem(text)
            else:
                widget.addItem(qicon, text)
            if (item == selected):
                target_index = index
        widget.setCurrentIndex(target_index)
    finally:
        self._guard &= (~ SELECTED_GUARD)

dataset/ETHPy150Open ContinuumIO/ashiba/enaml/enaml/qt/qt_object_combo.py QtObjectCombo.refresh_items/original