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)
def fill_combo(self): 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 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) self.combobox.addItem(img, lbl) else: self.combobox.addItem(lbl) self.combobox.blockSignals(False)
def create_plot(self, options): logo_path = configtools.get_image_file_path("guiqwt.svg") logo = QtGui.QLabel() logo.setPixmap(QtGui.QPixmap(logo_path)) logo.setAlignment(QtCore.Qt.AlignCenter) self.plot_layout.addWidget(logo, 1, 1) logo_txt = QtGui.QLabel("Powered by <b>guiqwt</b>") logo_txt.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop) self.plot_layout.addWidget(logo_txt, 2, 1) self.stamp_gbox = gdq.DataSetEditGroupBox("Dots", DotArrayParam) try: # guiqwt v3: self.stamp_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_params) except AttributeError: # guiqwt v2: from guidata.qt.QtCore import SIGNAL self.connect(self.stamp_gbox, SIGNAL("apply_button_clicked()"), self.apply_params) self.plot_layout.addWidget(self.stamp_gbox, 0, 1) options = dict(title="Main plot") gqp.ImageDialog.create_plot(self, options, 0, 0, 3, 1)
def create_plot(self, options): logo_path = configtools.get_image_file_path("guiqwt.svg") logo = QtGui.QLabel() logo.setPixmap(QtGui.QPixmap(logo_path)) logo.setAlignment(QtCore.Qt.AlignCenter) self.plot_layout.addWidget(logo, 1, 1) logo_txt = QtGui.QLabel("Powered by <b>guiqwt</b>") logo_txt.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop) self.plot_layout.addWidget(logo_txt, 2, 1) self.stamp_gbox = gdq.DataSetEditGroupBox("Dots", DotArrayParam) try: # guiqwt v3: self.stamp_gbox.SIG_APPLY_BUTTON_CLICKED.connect(self.apply_params) except AttributeError: # guiqwt v2: from guidata.qt.QtCore import SIGNAL self.connect(self.stamp_gbox, SIGNAL("apply_button_clicked()"), self.apply_params) self.plot_layout.addWidget(self.stamp_gbox, 0, 1) options = dict(title="Main plot") gqp.ImageDialog.create_plot(self, options, 0, 0, 3, 1)