def initialize_widget(self): if self.is_radio: for button in self._buttons: button.toggled.disconnect(self.index_changed) self.vbox.removeWidget(button) button.deleteLater() self._buttons = [] else: self.combobox.blockSignals(True) while self.combobox.count(): self.combobox.removeItem(0) _choices = self.item.get_prop_value("data", "choices") for key, lbl, img in _choices: if self.is_radio: button = QRadioButton(lbl, self.group) if img: if is_text_string(img): if not osp.isfile(img): img = get_image_file_path(img) img = QIcon(img) elif isinstance(img, collections.Callable): img = img(key) if self.is_radio: button.setIcon(img) else: self.combobox.addItem(img, lbl) elif not self.is_radio: self.combobox.addItem(lbl) if self.is_radio: self._buttons.append(button) self.vbox.addWidget(button) button.toggled.connect(self.index_changed) if not self.is_radio: self.combobox.blockSignals(False)