def update_bc_editor(self): if not self.bc_editor: return widgets = (self.ui.minimum, self.ui.maximum) new_range = [x.value() for x in widgets] with block_signals(self.bc_editor): self.bc_editor.ui_range = new_range
def update_gui(self): style = self.style with block_signals(*self.all_widgets): self.ui.marker.setCurrentText(style['marker']) self.ui.marker_size.setValue(style['s']) self.ui.face_color.setText(style['facecolors']) self.ui.edge_color.setText(style['edgecolors']) self.update_button_colors()
def ensure_min_max_space(self, one_to_change): # Keep the maximum at least one increment ahead of the minimum if self.ui.maximum.value() > self.ui.minimum.value(): return if one_to_change == 'max': w = self.ui.maximum v = self.ui.minimum.value() + 1 a = '_ui_max' else: w = self.ui.minimum v = self.ui.maximum.value() - 1 a = '_ui_min' with block_signals(w): w.setValue(v) interpolated = np.interp(v, (0, NUM_INCREMENTS), self.data_range) setattr(self, a, interpolated)
def load_settings(self): settings = HexrdConfig().config['calibration'].get('wppf') if not settings: return with block_signals(*self.all_widgets): for k, v in settings.items(): if k == 'params' and isinstance(v, dict): # The older WPPF dialog used a dict. Skip this # as it is no longer compatible. continue if not hasattr(self, k): # Skip it... continue setattr(self, k, v) # Add/remove params depending on what are allowed self.update_params()
def update_table(self): table = self.ui.table # Keep the same scroll position scrollbar = table.verticalScrollBar() scroll_value = scrollbar.value() with block_signals(table): self.clear_table() self.ui.table.setRowCount(len(self.params.param_dict)) for i, (key, param) in enumerate(self.params.param_dict.items()): name = param.name w = self.create_label(name) table.setItem(i, COLUMNS['name'], w) w = self.create_value_spinbox(self.convert(name, param.value)) table.setCellWidget(i, COLUMNS['value'], w) w = self.create_minimum_spinbox(self.convert(name, param.lb)) table.setCellWidget(i, COLUMNS['minimum'], w) w = self.create_maximum_spinbox(self.convert(name, param.ub)) table.setCellWidget(i, COLUMNS['maximum'], w) w = self.create_vary_checkbox(param.vary) table.setCellWidget(i, COLUMNS['vary'], w) # During event processing, it looks like the scrollbar gets resized # so its maximum is one less than one it actually is. Thus, if we # set the value to the maximum right now, it will end up being one # less than the actual maximum. # Thus, we need to post an event to the event loop to set the # scroll value after the other event processing. This works, but # the UI still scrolls back one and then to the maximum. So it # doesn't look that great. FIXME: figure out how to fix this. QTimer.singleShot(0, lambda: scrollbar.setValue(scroll_value))
def bc_editor_modified(self): with block_signals(self.ui.minimum, self.ui.maximum): self.ui.minimum.setValue(self.bc_editor.ui_min) self.ui.maximum.setValue(self.bc_editor.ui_max) self.range_edited()
def update_gui(self): with block_signals(self.ui.display_wppf_plot): self.display_wppf_plot = HexrdConfig().display_wppf_plot self.update_background_parameters() self.update_table()
def update_contrast(self): with block_signals(self, self.ui.contrast): self.ui_contrast = self.contrast
def update_brightness(self): with block_signals(self, self.ui.brightness): self.ui_brightness = self.brightness
def ui_range(self, v): with block_signals(self, self.ui.minimum, self.ui.maximum): self.ui_min = v[0] self.ui_max = v[1] self.modified()
def vertical_modified(self, v): # Set the horizontal to be 1 - vertical with block_signals(self.ui.horizontal): self.ui.horizontal.setValue(1 - v)