def update_palette_controls(self): """Update palette controls from internal QPalette""" for key, entries in self.palette_entries.items(): for subkey in entries: color = self._palette.color(getattr(self._palette, subkey)) btn = self.pickers[key][subkey] with block_signals(btn): btn.color = color
def _cbo_changed(self, cbo, index): branch = cbo.itemData(index) stream = VisualLogStream(self.plugin.ui) try: checkout_branch(branch, stream) except ValueError: with block_signals(cbo): cbo.setCurrentIndex(self._prev_indices[cbo]) finally: diag = getattr(stream, 'dialog', None) if diag is not None: diag.btn_close.setEnabled(True) self._prev_indices[cbo] = index
def update_controls_from_fig(self): p = self._cur_plot if p is None: self.sl_level.setValue(0.0) self.sl_window.setValue(0.0) self.chk_log.setChecked(False) self.disable() else: self.enable() imin, imax = self._plot_minmax() with block_signals(self.sl_level): self.sl_level.setRange(imin, imax) self.sl_level.setValue(p.vmin) self.lbl_level.setText(self.LevelLabel + ": %.2G" % p.vmin) with block_signals(self.sl_window): self.sl_window.setRange(0, imax - imin) window = p.vmax - p.vmin self.sl_window.setValue(window) self.lbl_window.setText(self.WindowLabel + ": %.2G" % window) with block_signals(self.chk_auto): auto = _auto_contrast(p) state = QtCore.Qt.Checked if all(auto) else ( QtCore.Qt.PartiallyChecked if any(auto) else QtCore.Qt.Unchecked) self.chk_auto.setCheckState(state) if p.ax.images: with block_signals(self.chk_log): self.chk_log.setEnabled(True) norm = isinstance(p.ax.images[-1].norm, SymLogNorm) self.chk_log.setChecked(norm) else: self.chk_log.setEnabled(False)
def set_signal(self, signal): self.signal = signal self.setWindowTitle(tr("Element picker")) if self.isEDS(): self.map_btn.show() else: self.map_btn.hide() if signal is None or signal.signal is None: self.set_enabled(False) return else: self.set_enabled(True) # Enable markers if plot has any with block_signals(self.chk_markers): markers = (hasattr(signal.signal, '_xray_markers') and bool(signal.signal._xray_markers)) self.chk_markers.setChecked(markers) # Make sure we have the Sample node, and Sample.elements if not hasattr(signal.signal.metadata, 'Sample'): signal.signal.metadata.add_node('Sample') if not hasattr(signal.signal.metadata.Sample, 'elements'): signal.signal.metadata.Sample.elements = [] self._set_elements(signal.signal.metadata.Sample.elements) # Disable elements which hyperspy does not accept hsyp_elem = list(elements_db.keys()) for w in self.table.children(): if isinstance(w, ExClickLabel): elem = w.text() if elem not in hsyp_elem: self.table.disable_element(elem) else: self.table.enable_element(elem)