def initialize_content(self): # Constraints dv = QDoubleValidator(self._content.ei_guess_edit) dv.setBottom(0.0) self._content.ei_guess_edit.setValidator(dv) if "SNS" != self._facility_name: util.set_valid(self._content.ei_guess_edit, False) self._content.tzero_guess_edit.setValidator(QDoubleValidator(self._content.tzero_guess_edit)) self._content.etr_low_edit.setValidator(QDoubleValidator(self._content.etr_low_edit)) self._content.etr_width_edit.setValidator(QDoubleValidator(self._content.etr_width_edit)) self._content.etr_high_edit.setValidator(QDoubleValidator(self._content.etr_high_edit)) self._content.monitor1_specid_edit.setValidator(QIntValidator(self._content.monitor1_specid_edit)) self._content.monitor2_specid_edit.setValidator(QIntValidator(self._content.monitor2_specid_edit)) # Default states self._handle_tzero_guess(self._content.use_ei_guess_chkbox.isChecked()) # Connections self._content.sample_browse.clicked.connect(self._sample_browse) self._content.detcal_browse.clicked.connect(self._detcal_browse) self._content.hardmask_browse.clicked.connect(self._hardmask_browse) self._content.grouping_browse.clicked.connect(self._grouping_browse) self._content.use_ei_guess_chkbox.stateChanged.connect(self._handle_tzero_guess) self._content.savedir_browse.clicked.connect(self._savedir_browse) # Validated widgets self._connect_validated_lineedit(self._content.sample_edit) self._connect_validated_lineedit(self._content.ei_guess_edit) self._connect_validated_lineedit(self._content.savedir_edit)
def initialize_content(self): # Constraints for widget in [ self._content.median_test_high_edit, self._content.median_test_low_edit, self._content.median_test_out_high_edit, self._content.median_test_out_low_edit, self._content.errorbar_crit_edit, self._content.ratio_var_crit_edit, self._content.sambkg_median_test_high_edit, self._content.sambkg_median_test_low_edit, self._content.sambkg_errorbar_crit_edit ]: dvp = QDoubleValidator(widget) dvp.setBottom(0.0) widget.setValidator(dvp) for widget in [ self._content.tof_start_edit, self._content.tof_end_edit ]: ivp = QIntValidator(widget) ivp.setBottom(0) widget.setValidator(ivp) # Connections self._content.det_van2_browse.clicked.connect(self._det_van2_browse)
def initialize_content(self): # Constraints for widget in [ self._content.median_test_high_edit, self._content.median_test_low_edit, self._content.median_test_out_high_edit, self._content.median_test_out_low_edit, self._content.errorbar_crit_edit, self._content.ratio_var_crit_edit, self._content.sambkg_median_test_high_edit, self._content.sambkg_median_test_low_edit, self._content.sambkg_errorbar_crit_edit ]: dvp = QDoubleValidator(widget) dvp.setBottom(0.0) widget.setValidator(dvp) for widget in [self._content.tof_start_edit, self._content.tof_end_edit]: ivp = QIntValidator(widget) ivp.setBottom(0) widget.setValidator(ivp) # Connections self._content.det_van2_browse.clicked.connect(self._det_van2_browse)
def initialize_content(self): """ Initialize content/UI """ # Constraints/Validator iv4 = QIntValidator(self._content.maxchunksize_edit) iv4.setBottom(0) self._content.maxchunksize_edit.setValidator(iv4) dv0 = QDoubleValidator(self._content.unwrap_edit) self._content.unwrap_edit.setValidator(dv0) dv2 = QDoubleValidator(self._content.lowres_edit) self._content.lowres_edit.setValidator(dv2) dv3 = QDoubleValidator(self._content.cropwavelengthmin_edit) dv3.setBottom(0.0) self._content.cropwavelengthmin_edit.setValidator(dv3) dv3b = QDoubleValidator(self._content.lineEdit_croppedWavelengthMax) dv3b.setBottom(0.1) self._content.lineEdit_croppedWavelengthMax.setValidator(dv3b) dv4 = QDoubleValidator(self._content.removepromptwidth_edit) dv4.setBottom(0.0) self._content.removepromptwidth_edit.setValidator(dv4) self._content.removepromptwidth_edit.setText("50.0") dv5 = QDoubleValidator(self._content.vanpeakfwhm_edit) dv5.setBottom(0.0) self._content.vanpeakfwhm_edit.setValidator(dv5) dv6 = QDoubleValidator(self._content.vanpeaktol_edit) dv6.setBottom(0.0) self._content.vanpeaktol_edit.setValidator(dv6) dv7 = QDoubleValidator(self._content.scaledata_edit) dv7.setBottom(0.0) self._content.scaledata_edit.setValidator(dv7) # Default states self._content.stripvanpeaks_chkbox.setChecked(True) self._syncStripVanPeakWidgets(True) self._content.preserveevents_checkbox.setChecked(True) dv8 = QDoubleValidator(self._content.filterbadpulses_edit) dv8.setBottom(0.0) self._content.filterbadpulses_edit.setValidator(dv8) self._content.filterbadpulses_edit.setText("95.") # Connections from action/event to function to handle self._content.stripvanpeaks_chkbox.clicked.connect(self._stripvanpeaks_clicked) self._content.help_button.clicked.connect(self._show_help) # Handler for events # TODO - Need to add an event handler for the change of instrument and facility # Validated widgets return
def initialize_content(self): # Set some validators self._content.monint_low_edit.setValidator(QIntValidator(self._content.monint_low_edit)) self._content.monint_high_edit.setValidator(QIntValidator(self._content.monint_high_edit)) self._content.tof_start_edit.setValidator(QIntValidator(self._content.tof_start_edit)) self._content.tof_end_edit.setValidator(QIntValidator(self._content.tof_end_edit)) # Make group for incident beam normalisation radio buttons self.incident_beam_norm_grp = QButtonGroup() self.incident_beam_norm_grp.addButton(self._content.none_rb, 0) self.incident_beam_norm_grp.addButton(self._content.current_rb, 1) self.incident_beam_norm_grp.addButton(self._content.monitor1_rb, 2) self._monitor_intrange_widgets_state(self._content.monitor1_rb.isChecked()) self._content.monitor1_rb.toggled.connect(self._monitor_intrange_widgets_state) self._detvan_intrange_widgets_state(self._content.van_int_cb.isChecked()) self._content.van_int_cb.toggled.connect(self._detvan_intrange_widgets_state) self._content.use_procdetvan_cb.toggled.connect(self._detvan_widgets_opp_state) self._save_detvan_widgets_state(self._content.save_procdetvan_cb.isChecked()) self._content.save_procdetvan_cb.toggled.connect(self._save_detvan_widgets_state) # Connections self._content.van_input_browse.clicked.connect(self._detvan_browse) self._content.save_procdetvan_save.clicked.connect(self._save_procdetvan_save)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Load the ui file and attach it to this instance loadUi(os.path.join(os.path.dirname(__file__), "ui", "export_size.ui"), self) # Add some simple validators to the text boxes self.height_line_edit.setValidator(QIntValidator()) self.width_line_edit.setValidator(QIntValidator())
def __init__(self, editor): QDialog.__init__(self, editor, Qt.WindowTitleHint | Qt.WindowCloseButtonHint) # Destroying the C++ object right after closing the dialog box, # otherwise it may be garbage-collected in another QThread # (e.g. the editor's analysis thread in Spyder), thus leading to # a segmentation fault on UNIX or an application crash on Windows self.setAttribute(Qt.WA_DeleteOnClose) self.lineno = None self.editor = editor self.setWindowTitle(_("Editor")) self.setModal(True) label = QLabel(_("Go to line:")) self.lineedit = QLineEdit() validator = QIntValidator(self.lineedit) validator.setRange(1, editor.get_line_count()) self.lineedit.setValidator(validator) self.lineedit.textChanged.connect(self.text_has_changed) cl_label = QLabel(_("Current line:")) cl_label_v = QLabel("<b>%d</b>" % editor.get_cursor_line_number()) last_label = QLabel(_("Line count:")) last_label_v = QLabel("%d" % editor.get_line_count()) glayout = QGridLayout() glayout.addWidget(label, 0, 0, Qt.AlignVCenter | Qt.AlignRight) glayout.addWidget(self.lineedit, 0, 1, Qt.AlignVCenter) glayout.addWidget(cl_label, 1, 0, Qt.AlignVCenter | Qt.AlignRight) glayout.addWidget(cl_label_v, 1, 1, Qt.AlignVCenter) glayout.addWidget(last_label, 2, 0, Qt.AlignVCenter | Qt.AlignRight) glayout.addWidget(last_label_v, 2, 1, Qt.AlignVCenter) bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Vertical, self) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) btnlayout = QVBoxLayout() btnlayout.addWidget(bbox) btnlayout.addStretch(1) ok_button = bbox.button(QDialogButtonBox.Ok) ok_button.setEnabled(False) self.lineedit.textChanged.connect( lambda text: ok_button.setEnabled(len(text) > 0)) layout = QHBoxLayout() layout.addLayout(glayout) layout.addLayout(btnlayout) self.setLayout(layout) self.lineedit.setFocus()
def load_from_config(self): # Appearance page self.darkThemeDefaultCheckBox.setChecked(CONFIG['dark_theme_default']) self.loggerTableFont.setCurrentFont(QFont(CONFIG['logger_table_font'])) self.loggerTableFontSize.setValue(CONFIG['logger_table_font_size']) self.textViewFont.setCurrentFont(QFont( CONFIG['text_view_dialog_font'])) self.textViewFontSize.setValue(CONFIG['text_view_dialog_font_size']) self.loggerTableRowHeight.setValue(CONFIG['logger_row_height']) self.excIndicationComboBox.setCurrentIndex( CONFIG['exception_indication']) self.timeFormatLine.setText(CONFIG['time_format_string']) self.timeFormatLine.setValidator(self.time_format_validator) self.timeFormatLine.textChanged.connect(self.time_format_valid) # Search self.searchOpenDefaultCheckBox.setChecked( CONFIG['search_open_default']) self.searchRegexDefaultCheckBox.setChecked( CONFIG['search_regex_default']) self.searchCaseSensitiveDefaultCheckBox.setChecked( CONFIG['search_casesensitive_default']) self.searchWildcardDefaultCheckBox.setChecked( CONFIG['search_wildcard_default']) # Server page self.listenHostLine.setText(CONFIG['listen_host']) self.listenPortLine.setValidator(QIntValidator(0, 65535, self)) self.listenPortLine.setText(str(CONFIG['listen_port'])) self.singleTabCheckBox.setChecked(CONFIG['single_tab_mode_default']) self.extraModeCheckBox.setChecked(CONFIG['extra_mode_default']) self.useSystemProxyCheckBox.setChecked(CONFIG['use_system_proxy']) if MSGPACK_SUPPORT: self.serializationFormatCombo.addItem("msgpack") if CBOR_SUPPORT: self.serializationFormatCombo.addItem("cbor") i = self.serializationFormatCombo.findText( CONFIG['default_serialization_format']) if i != -1: self.serializationFormatCombo.setCurrentIndex(i) # Advanced page self.logLevelLine.setValidator(QIntValidator(0, 1000, self)) self.logLevelLine.setText(str(CONFIG['console_logging_level'])) self.benchmarkCheckBox.setChecked(CONFIG['benchmark']) self.benchmarkIntervalLine.setValidator( QDoubleValidator(0, 1000, 9, self)) self.benchmarkIntervalLine.setText(str(CONFIG['benchmark_interval'])) self.lightThemeNativeCheckBox.setChecked( CONFIG['light_theme_is_native']) self.server_restart_needed = False
def __init__(self, parent=None, *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.model_items = None self._smoothing_thread = None # Worker thread self.kernel = None # One of the sub-dicts in KERNEL_REGISTRY self.function = None # function from `~specutils.manipulation.smoothing` self.data = None # Current `~specviz.core.items.DataItem` self.size = None # Current kernel size self._already_loaded = False # # Do the first-time loading and initialization of the GUI # loadUi(os.path.abspath( os.path.join(os.path.dirname(__file__), ".", "smoothing.ui")), self) self.smooth_button.clicked.connect(self.accept) self.cancel_button.clicked.connect(self.close) self.data_combo.currentIndexChanged.connect(self._on_data_change) for key in KERNEL_REGISTRY: kernel = KERNEL_REGISTRY[key] self.kernel_combo.addItem(kernel["name"], key) self.kernel_combo.currentIndexChanged.connect(self._on_kernel_change) # Add integer validator to size input field self.size_input.setValidator(QIntValidator())
def __init__(self, parent=None): super().__init__(parent) self.minimum = 0 self.maximum = 100 self.parent = parent self.value = 0 self.singleStep = 1 self.hover = False self.border_radius = 8 self.rate = 0.25 self.up_arrow_poly = QPolygon() self.down_arrow_poly = QPolygon() self.back_color = QColor(108, 108, 115) self.text_color = QColor(255, 255, 255) self.arrow_activate_color = QColor(255, 255, 255) self.arrow_deactivate_color = QColor(200, 200, 200) self.up_arrow_color = self.arrow_deactivate_color self.down_arrow_color = self.arrow_deactivate_color self.label_width = 0 self.drop_thick = 1.5 self.setMinimumHeight(25) self.setMinimumWidth(50) self.setMouseTracking(True) self.lineEdit = PLineEdit(self) self.validator = QIntValidator(self.minimum, self.maximum) self.init_ui()
def __init__(self, parent: QWidget, axis: int): super().__init__(parent=parent) self.axis = axis self.qt_dims = parent self.dims = parent.dims self.axis_label = None self.slider = None self.play_button = None self.curslice_label = QLineEdit(self) self.curslice_label.setToolTip(f'Current slice for axis {axis}') # if we set the QIntValidator to actually reflect the range of the data # then an invalid (i.e. too large) index doesn't actually trigger the # editingFinished event (the user is expected to change the value)... # which is confusing to the user, so instead we use an IntValidator # that makes sure the user can only enter integers, but we do our own # value validation in change_slice self.curslice_label.setValidator(QIntValidator(0, 999999)) def change_slice(): val = int(self.curslice_label.text()) max_allowed = self.dims.max_indices[self.axis] if val > max_allowed: val = max_allowed self.curslice_label.setText(str(val)) self.curslice_label.clearFocus() self.qt_dims.setFocus() self.dims.set_point(self.axis, val) self.curslice_label.editingFinished.connect(change_slice) self.totslice_label = QLabel(self) self.totslice_label.setToolTip(f'Total slices for axis {axis}') self.curslice_label.setObjectName('slice_label') self.totslice_label.setObjectName('slice_label') sep = QFrame(self) sep.setFixedSize(1, 14) sep.setObjectName('slice_label_sep') self._fps = 10 self._minframe = None self._maxframe = None self._loop_mode = LoopMode.LOOP layout = QHBoxLayout() self._create_axis_label_widget() self._create_range_slider_widget() self._create_play_button_widget() layout.addWidget(self.axis_label) layout.addWidget(self.play_button) layout.addWidget(self.slider, stretch=1) layout.addWidget(self.curslice_label) layout.addWidget(sep) layout.addWidget(self.totslice_label) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(2) self.setLayout(layout) self.dims.events.axis_labels.connect(self._pull_label)
def __init__(self, parent: QWidget, axis: int): super().__init__(parent=parent) self.axis = axis self.qt_dims = parent self.dims = parent.dims self.axis_label = None self.slider = None self.play_button = None self.curslice_label = QLineEdit(self) self.curslice_label.setToolTip( trans._('Current slice for axis {axis}', axis=axis)) # if we set the QIntValidator to actually reflect the range of the data # then an invalid (i.e. too large) index doesn't actually trigger the # editingFinished event (the user is expected to change the value)... # which is confusing to the user, so instead we use an IntValidator # that makes sure the user can only enter integers, but we do our own # value validation in self.change_slice self.curslice_label.setValidator(QIntValidator(0, 999999)) self.curslice_label.editingFinished.connect(self._set_slice_from_label) self.totslice_label = QLabel(self) self.totslice_label.setToolTip( trans._('Total slices for axis {axis}', axis=axis)) self.curslice_label.setObjectName('slice_label') self.totslice_label.setObjectName('slice_label') sep = QFrame(self) sep.setFixedSize(1, 14) sep.setObjectName('slice_label_sep') settings = get_settings() self._fps = settings.application.playback_fps connect_setattr_value(settings.application.events.playback_fps, self, "fps") self._minframe = None self._maxframe = None self._loop_mode = settings.application.playback_mode connect_setattr_value(settings.application.events.playback_mode, self, "loop_mode") layout = QHBoxLayout() self._create_axis_label_widget() self._create_range_slider_widget() self._create_play_button_widget() layout.addWidget(self.axis_label) layout.addWidget(self.play_button) layout.addWidget(self.slider, stretch=1) layout.addWidget(self.curslice_label) layout.addWidget(sep) layout.addWidget(self.totslice_label) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(2) layout.setAlignment(Qt.AlignVCenter) self.setLayout(layout) self.dims.events.axis_labels.connect(self._pull_label)
def __init__(self, parent=None): super(RedisItemEditor, self).__init__(parent) self.load_ui() self.__original_item = None self.__item = None ui = self.ui layout = QStackedLayout(ui.type_editor) layout.setContentsMargins(3, 3, 3, 3) self.none_editor = QWidget() self.simple_editor = SimpleEditor() self.hash_editor = MultiEditor() self.seq_editor = MultiEditor() self.seq_editor.ui.table.horizontalHeader().setVisible(False) self.set_editor = MultiEditor() self.set_editor.ui.table.horizontalHeader().setVisible(False) layout.addWidget(self.none_editor) layout.addWidget(self.simple_editor) layout.addWidget(self.hash_editor) layout.addWidget(self.seq_editor) layout.addWidget(self.set_editor) self.type_editor_map = { "none": self.none_editor, "string": self.simple_editor, "hash": self.hash_editor, "list": self.seq_editor, "set": self.set_editor, } ttl_validator = QIntValidator() ttl_validator.setBottom(-1) ui.ttl_value.setValidator(ttl_validator) ui.key_name.textChanged.connect(self.__on_key_name_changed) ui.key_name.returnPressed.connect(self.__on_key_name_applied) ui.ttl_value.textChanged.connect(self.__on_ttl_changed) ui.ttl_value.returnPressed.connect(self.__on_ttl_applied) ui.apply_button.clicked.connect(self.__on_apply) ui.refresh_button.clicked.connect(self.__on_refresh) ui.undo_button.clicked.connect(self.__on_undo) ui.persist_button.clicked.connect(self.__on_persist) ui.delete_button.clicked.connect(self.__on_delete)
def _setup_ui(self): """ Set up the UI for the BatchProcessingView """ layout = QVBoxLayout() self.setLayout(layout) # Workflow config self.field_workflow_config = FileInput( mode=FileInputMode.FILE, filter="Json file (*.json)", placeholder_text="Load a JSON workflow file..." ) self.field_workflow_config.file_selected.connect(self._form_field_changed) row1 = FormRow("1. Load workflow:", self.field_workflow_config) # Channel index self.field_channel = QLineEdit("0") self.field_channel.setValidator(QIntValidator(bottom=0)) self.field_channel.textChanged.connect(self._form_field_changed) row2 = FormRow("2. Structure channel index:", self.field_channel) # Input dir self.field_input_dir = FileInput(mode=FileInputMode.DIRECTORY, placeholder_text="Select a directory...") self.field_input_dir.file_selected.connect(self._form_field_changed) row3 = FormRow("3. Input directory:", self.field_input_dir) # Output dir self.field_output_dir = FileInput(mode=FileInputMode.DIRECTORY, placeholder_text="Select a directory...") self.field_output_dir.file_selected.connect(self._form_field_changed) row4 = FormRow("4. Output directory:", self.field_output_dir) # Help label = QLabel() label.setText("Supported file formats: .tif, .tiff, .czi, .ome.tif, .ome.tiff") form = QWidget() form.setLayout(Form([row1, row2, row3, row4])) layout.addWidget(form) layout.addWidget(label) # Submit self.btn_run_batch = QPushButton("Run Batch") self.btn_run_batch.clicked.connect(self._btn_run_batch_clicked) self.update_button(enabled=False) layout.addWidget(self.btn_run_batch) # Progress bar self.progress_bar = QProgressBar() self.progress_bar.setRange(0, 100) self.progress_bar.setValue(0) self.progress_bar.setTextVisible(True) self.progress_bar.setVisible(False) layout.addWidget(self.progress_bar)
def _init_ui(self): # Widgets validator = QIntValidator() validator.setBottom(0) self._txt_start_channel = QLineEdit() self._txt_start_channel.setValidator(validator) self._txt_start_channel.setAccessibleName('Start channel') self._txt_end_channel = QLineEdit() self._txt_end_channel.setValidator(validator) self._txt_end_channel.setAccessibleName("End channel") # Layouts layout = _ConditionWidget._init_ui(self) layout.addRow('<i>Start channel</i>', self._txt_start_channel) layout.addRow('<i>End channel</i>', self._txt_end_channel) # Signals self._txt_start_channel.textEdited.connect(self.edited) self._txt_end_channel.textEdited.connect(self.edited) return layout
def createEditor(self, parent, option, index): """Create editor widget""" model = index.model() # TODO: dtype should be taken from the model instead (or even from the actual value?) value = model.get_value(index) if self.dtype.name == "bool": # toggle value value = not value model.setData(index, to_qvariant(value)) return elif value is not np.ma.masked: minvalue, maxvalue = self.minvalue, self.maxvalue if minvalue is not None and maxvalue is not None: msg = "value must be between %s and %s" % (minvalue, maxvalue) elif minvalue is not None: msg = "value must be >= %s" % minvalue elif maxvalue is not None: msg = "value must be <= %s" % maxvalue else: msg = None # Not using a QSpinBox for integer inputs because I could not find # a way to prevent the spinbox/editor from closing if the value is # invalid. Using the builtin minimum/maximum of the spinbox works # but that provides no message so it is less clear. editor = QLineEdit(parent) if is_number(self.dtype): validator = QDoubleValidator(editor) if is_float(self.dtype) \ else QIntValidator(editor) if minvalue is not None: validator.setBottom(minvalue) if maxvalue is not None: validator.setTop(maxvalue) editor.setValidator(validator) def on_editor_text_edited(): if not editor.hasAcceptableInput(): QToolTip.showText(editor.mapToGlobal(QPoint()), msg) else: QToolTip.hideText() if msg is not None: editor.textEdited.connect(on_editor_text_edited) editor.setFont(self.font) editor.setAlignment(Qt.AlignRight) editor.destroyed.connect(self.on_editor_destroyed) self.editor_count += 1 return editor
def setup_ui(self): loadUi(os.path.join(UI_PATH, "model_fitting_plugin.ui"), self.contents) # Hide the advanced settings initially self.contents.group_box_advanced_settings.hide() # Create validators advanced settings inputs max_iter_valid = QIntValidator(1, 9999, self) self.contents.max_iterations_line_edit.setValidator(max_iter_valid) rel_err_valid = QDoubleValidator(0, 9999.0, 20, self) self.contents.relative_error_line_edit.setValidator(rel_err_valid) eps_valid = QDoubleValidator(0, 9999.0, 20, self) self.contents.epsilon_line_edit.setValidator(eps_valid)
def createIntegerLineEdit(self, minimum=None, maximum=None, placeholder=""): line_edit = ClearableLineEdit(placeholder=placeholder) validator = QIntValidator() if minimum is not None: validator.setBottom(minimum) if maximum is not None: validator.setTop(maximum) line_edit.setValidator(validator) return line_edit
def __init__(self, *args, **kwargs): super(Parameters, self).__init__(*args, **kwargs) self.setFrameStyle(QFrame.Panel | QFrame.Raised) self.contentLayout = QGridLayout() self.voltage = 3000 self.delay = 600.00 self.setpointVoltageLabel = QLabel("Fixed voltage [3000 to 7000] V") self.setpointVoltageSettingLabel = QLabel() self.setpointVoltageInp = QLineEdit() self.setpointVoltageInp.setMaximumWidth(100) self.setpointVoltageInp.setValidator(QIntValidator(3000, 7000)) self.setpointVoltageInp.setToolTip("New fixed voltage setpoint.") self.contentLayout.addWidget(self.setpointVoltageLabel, 0, 0, 1, 1) self.contentLayout.addWidget(self.setpointVoltageInp, 0, 1, 1, 1) self.contentLayout.addWidget(self.setpointVoltageSettingLabel, 0, 2, 1, 1) self.stepToFixDelayLabel = QLabel("Step to Fixed delay in seconds") self.stepToFixDelaySettingLabel = QLabel() self.stepToFixDelayInp = QLineEdit() self.stepToFixDelayInp.setMaximumWidth(100) self.stepToFixDelayInp.setValidator(QDoubleValidator(1, 1440, 2)) self.stepToFixDelayInp.setToolTip( "Delay between toStep and toFixed calls.") self.contentLayout.addWidget(self.stepToFixDelayLabel, 1, 0, 1, 1) self.contentLayout.addWidget(self.stepToFixDelayInp, 1, 1, 1, 1) self.contentLayout.addWidget(self.stepToFixDelaySettingLabel, 1, 2, 1, 1) self.setButton = QPushButton("Confirm") self.setButton.clicked.connect(self.confirm) self.setButton.setToolTip("Apply settings") self.contentLayout.addWidget(self.setButton, 3, 1, 1, 1) self.setLayout(self.contentLayout) self.confirm()
def __init__(self, *args, **kwargs): super(ParametersFrame, self).__init__(*args, **kwargs) self.setFrameStyle(QFrame.Panel | QFrame.Raised) self.contentLayout = QGridLayout() self.setpointVoltageLabel = QLabel("Fixed voltage [3000 to 7000] V") self.setpointVoltageSettingLabel = QLabel() self.setpointVoltageInp = QLineEdit() self.setpointVoltageInp.setMaximumWidth(100) self.setpointVoltageInp.setValidator(QIntValidator(3000, 7000)) self.setpointVoltageInp.setToolTip("Final voltage setpoint.") self.setpointVoltageInp.setText("3000") self.contentLayout.addWidget(self.setpointVoltageLabel, 0, 0, 1, 1) self.contentLayout.addWidget(self.setpointVoltageInp, 0, 1, 1, 1) self.contentLayout.addWidget(self.setpointVoltageSettingLabel, 0, 2, 1, 1) self.stepToFixDelayLabel = QLabel("Step to Fixed delay (mm:ss)") self.stepToFixDelaySettingLabel = QLabel() self.stepToFixDelayInp = QLineEdit() self.stepToFixDelayInp.setMaximumWidth(100) self.stepToFixDelayInp.setValidator( QRegExpValidator(QRegExp(MIN_SEC_PATTERN))) self.stepToFixDelayInp.setToolTip( "Delay between toStep and toFixed calls.") self.stepToFixDelayInp.setText("05:00") self.contentLayout.addWidget(self.stepToFixDelayLabel, 1, 0, 1, 1) self.contentLayout.addWidget(self.stepToFixDelayInp, 1, 1, 1, 1) self.contentLayout.addWidget(self.stepToFixDelaySettingLabel, 1, 2, 1, 1) self.setButton = QPushButton("Confirm") self.setButton.clicked.connect(self.confirm) self.setButton.setToolTip("Apply settings") self.contentLayout.addWidget(self.setButton, 3, 1, 1, 1) self.setLayout(self.contentLayout) self.confirm()
def initialize(self): self._setting = SETTINGS.get(self._setting_name) if self._setting is not None: val = self._setting.getValue() validator = None if type(val) == int: validator = QIntValidator() elif type(val) == float: validator = QDoubleValidator() self.setValidator(validator) if self._tmp_value: self.setDisplayValue(self._tmp_value) self._setting.setValue(self._tmp_value) else: self.setDisplayValue(self._setting.getValue()) self._setting.notify(self.setDisplayValue) self.editingFinished.connect(self.onEditingFinished)
def setup_ui(self): self.host = QLineEdit(self) self.host.setMinimumWidth(170) self.port = QLineEdit(self) self.port.setValidator(QIntValidator(0, 99999, self)) self.username = QLineEdit(self) self.password = QLineEdit(self) self.password.setEchoMode(QLineEdit.Password) self.password.editingFinished.connect( lambda: [self._connect() if self.password.text() else None]) host, user, uuid, port = self.gateway.get_current() self.host.setText(self.gateway._host or host or "") self.port.setText(self.gateway._port or port or "") self.username.setText(self.gateway._user or user or "") self.password.setText(os.getenv("OMERO_PASSWORD")) self.status = QLabel(self) self.status.setWordWrap(True) self.connect_btn = QPushButton("connect", self) self.connect_btn.clicked.connect(self._connect) self.login_form = QWidget(self) login_layout = QGridLayout(self.login_form) login_layout.setContentsMargins(0, 0, 0, 0) login_layout.addWidget(QLabel("host", self), 0, 0) login_layout.addWidget(self.host, 0, 1) login_layout.addWidget(QLabel("port", self), 1, 0) login_layout.addWidget(self.port, 1, 1) login_layout.addWidget(QLabel("username", self), 2, 0) login_layout.addWidget(self.username, 2, 1) login_layout.addWidget(QLabel("password", self), 3, 0) login_layout.addWidget(self.password, 3, 1) login_layout.addWidget(self.connect_btn, 4, 1) layout = QVBoxLayout(self) layout.addWidget(self.login_form) layout.addWidget(self.status)
def __init__(self, appdata: CnaData): QDialog.__init__(self) self.setWindowTitle("Configure COBRApy") self.appdata = appdata self.layout = QVBoxLayout() # allow MILP solvers only? avail_solvers = list(set(solvers.keys()) - {'scipy'}) # SCIPY currently not even usable for FBA h2 = QHBoxLayout() label = QLabel("Default solver:\n(set when loading a model)") h2.addWidget(label) self.default_solver = QComboBox() self.default_solver.addItems(avail_solvers) self.default_solver.setCurrentIndex(avail_solvers.index(interface_to_str(cobra.Configuration().solver))) h2.addWidget(self.default_solver) self.layout.addItem(h2) h9 = QHBoxLayout() label = QLabel("Solver for current model:") h9.addWidget(label) self.current_solver = QComboBox() self.current_solver.addItems(avail_solvers) self.current_solver.setCurrentIndex(avail_solvers.index(interface_to_str(appdata.project.cobra_py_model.problem))) h9.addWidget(self.current_solver) self.layout.addItem(h9) h7 = QHBoxLayout() label = QLabel( "Number of processes for multiprocessing (e.g. FVA):") h7.addWidget(label) self.num_processes = QLineEdit() self.num_processes.setFixedWidth(100) self.num_processes.setText(str(cobra.Configuration().processes)) validator = QIntValidator(1, cpu_count(), self) self.num_processes.setValidator(validator) h7.addWidget(self.num_processes) self.layout.addItem(h7) h8 = QHBoxLayout() label = QLabel( "Default tolerance:\n(set when loading a model)") h8.addWidget(label) self.default_tolerance = QLineEdit() self.default_tolerance.setFixedWidth(100) self.default_tolerance.setText(str(cobra.Configuration().tolerance)) validator = QDoubleValidator(self) validator.setBottom(1e-9) # probably a reasonable consensus value self.default_tolerance.setValidator(validator) h8.addWidget(self.default_tolerance) self.layout.addItem(h8) h10 = QHBoxLayout() label = QLabel( "Tolerance for current model:") h10.addWidget(label) self.current_tolerance = QLineEdit() self.current_tolerance.setFixedWidth(100) self.current_tolerance.setText(str(self.appdata.project.cobra_py_model.tolerance)) validator = QDoubleValidator(self) validator.setBottom(0) self.current_tolerance.setValidator(validator) h10.addWidget(self.current_tolerance) self.layout.addItem(h10) l2 = QHBoxLayout() self.button = QPushButton("Apply Changes") self.cancel = QPushButton("Close") l2.addWidget(self.button) l2.addWidget(self.cancel) self.layout.addItem(l2) self.setLayout(self.layout) self.cancel.clicked.connect(self.reject) self.button.clicked.connect(self.apply)
def __init__(self): super().__init__() self._validation_enabled = False self.resize(500, 300) self.setWindowTitle("Load Mask or Select ROI") # Initialize variables used with ROI selection group self._n_rows = 0 self._n_columns = 0 self._roi_active = False self._row_start = -1 self._column_start = -1 self._row_end = -1 self._column_end = -1 # ... with Mask group self._mask_active = False self._mask_file_path = "" self._default_directory = "" # Fields for entering spatial ROI coordinates self.validator_rows = QIntValidator() self.validator_rows.setBottom(1) self.validator_cols = QIntValidator() self.validator_cols.setBottom(1) self.le_roi_start_row = LineEditExtended() self.le_roi_start_row.setValidator(self.validator_rows) self.le_roi_start_row.editingFinished.connect( self.le_roi_start_row_editing_finished) self.le_roi_start_row.textChanged.connect( self.le_roi_start_row_text_changed) self.le_roi_start_col = LineEditExtended() self.le_roi_start_col.setValidator(self.validator_cols) self.le_roi_start_col.editingFinished.connect( self.le_roi_start_col_editing_finished) self.le_roi_start_col.textChanged.connect( self.le_roi_start_col_text_changed) self.le_roi_end_row = LineEditExtended() self.le_roi_end_row.setValidator(self.validator_rows) self.le_roi_end_row.editingFinished.connect( self.le_roi_end_row_editing_finished) self.le_roi_end_row.textChanged.connect( self.le_roi_end_row_text_changed) self.le_roi_end_col = LineEditExtended() self.le_roi_end_col.setValidator(self.validator_cols) self.le_roi_end_col.editingFinished.connect( self.le_roi_end_col_editing_finished) self.le_roi_end_col.textChanged.connect( self.le_roi_end_col_text_changed) self._text_map_size_base = " * Map size: " self.label_map_size = QLabel(self._text_map_size_base + "not set") # Group box for spatial ROI selection self.gb_roi = QGroupBox("Select ROI (in pixels)") set_tooltip( self.gb_roi, "Select rectangular <b>spatial ROI</b>. If <b>mask</b> is " "loaded, then ROI is applied to the masked data.", ) self.gb_roi.setCheckable(True) self.gb_roi.toggled.connect(self.gb_roi_toggled) self.gb_roi.setChecked(self._roi_active) vbox = QVBoxLayout() grid = QGridLayout() grid.addWidget(QLabel("Start position(*):"), 0, 0) grid.addWidget(QLabel("row"), 0, 1) grid.addWidget(self.le_roi_start_row, 0, 2) grid.addWidget(QLabel("column"), 0, 3) grid.addWidget(self.le_roi_start_col, 0, 4) grid.addWidget(QLabel("End position(*):"), 1, 0) grid.addWidget(QLabel("row"), 1, 1) grid.addWidget(self.le_roi_end_row, 1, 2) grid.addWidget(QLabel("column"), 1, 3) grid.addWidget(self.le_roi_end_col, 1, 4) vbox.addLayout(grid) vbox.addWidget(self.label_map_size) self.gb_roi.setLayout(vbox) # Widgets for loading mask self.pb_load_mask = QPushButton("Load Mask ...") self.pb_load_mask.clicked.connect(self.pb_load_mask_clicked) self._le_load_mask_default_text = "select 'mask' file" self.le_load_mask = LineEditReadOnly(self._le_load_mask_default_text) # Group box for setting mask self.gb_mask = QGroupBox("Set mask") set_tooltip( self.gb_mask, "Load <b>mask</b> from file. Active pixels in the mask are " "represented by positive integers. If <b>spatial ROI</b> is " "selected, then it is applied to the masked data.", ) self.gb_mask.setCheckable(True) self.gb_mask.toggled.connect(self.gb_mask_toggled) self.gb_mask.setChecked(self._mask_active) hbox = QHBoxLayout() hbox.addWidget(self.pb_load_mask) hbox.addWidget(self.le_load_mask) self.gb_mask.setLayout(hbox) # Yes/No button box self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_ok = self.button_box.button(QDialogButtonBox.Ok) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) vbox = QVBoxLayout() vbox.addWidget(self.gb_roi) vbox.addStretch(1) vbox.addWidget(self.gb_mask) vbox.addStretch(2) vbox.addWidget(self.button_box) self.setLayout(vbox) self._validation_enabled = True self._validate_all_widgets()
class DialogLoadMask(QDialog): """ Dialog box for selecting spatial ROI and mask. Typical use: default_dir = "/home/user/data" n_rows, n_columns = 15, 20 # Some values # Values that are changed by the dialog box roi = (2, 3, 11, 9) use_roi = True mask_f_path = "" use_mask = False dlg = DialogLoadMask() dlg.set_image_size(n_rows=n_rows, n_columns=n_columns) dlg.set_roi(row_start=roi[0], column_start=roi[1], row_end=roi[2], column_end=roi[3]) dlg.set_roi_active(use_roi) dlg.set_default_directory(default_dir) dlg.set_mask_file_path(mask_f_path) dlg.set_mask_file_active(use_mask) if dlg.exec() == QDialog.Accepted: # If success, then read the values back. Discard changes if rejected. roi = dlg.get_roi() use_roi = dlg.get_roi_active() mask_f_path = dlg.get_mask_file_path() use_mask = dlg.get_mask_file_active() """ def __init__(self): super().__init__() self._validation_enabled = False self.resize(500, 300) self.setWindowTitle("Load Mask or Select ROI") # Initialize variables used with ROI selection group self._n_rows = 0 self._n_columns = 0 self._roi_active = False self._row_start = -1 self._column_start = -1 self._row_end = -1 self._column_end = -1 # ... with Mask group self._mask_active = False self._mask_file_path = "" self._default_directory = "" # Fields for entering spatial ROI coordinates self.validator_rows = QIntValidator() self.validator_rows.setBottom(1) self.validator_cols = QIntValidator() self.validator_cols.setBottom(1) self.le_roi_start_row = LineEditExtended() self.le_roi_start_row.setValidator(self.validator_rows) self.le_roi_start_row.editingFinished.connect( self.le_roi_start_row_editing_finished) self.le_roi_start_row.textChanged.connect( self.le_roi_start_row_text_changed) self.le_roi_start_col = LineEditExtended() self.le_roi_start_col.setValidator(self.validator_cols) self.le_roi_start_col.editingFinished.connect( self.le_roi_start_col_editing_finished) self.le_roi_start_col.textChanged.connect( self.le_roi_start_col_text_changed) self.le_roi_end_row = LineEditExtended() self.le_roi_end_row.setValidator(self.validator_rows) self.le_roi_end_row.editingFinished.connect( self.le_roi_end_row_editing_finished) self.le_roi_end_row.textChanged.connect( self.le_roi_end_row_text_changed) self.le_roi_end_col = LineEditExtended() self.le_roi_end_col.setValidator(self.validator_cols) self.le_roi_end_col.editingFinished.connect( self.le_roi_end_col_editing_finished) self.le_roi_end_col.textChanged.connect( self.le_roi_end_col_text_changed) self._text_map_size_base = " * Map size: " self.label_map_size = QLabel(self._text_map_size_base + "not set") # Group box for spatial ROI selection self.gb_roi = QGroupBox("Select ROI (in pixels)") set_tooltip( self.gb_roi, "Select rectangular <b>spatial ROI</b>. If <b>mask</b> is " "loaded, then ROI is applied to the masked data.", ) self.gb_roi.setCheckable(True) self.gb_roi.toggled.connect(self.gb_roi_toggled) self.gb_roi.setChecked(self._roi_active) vbox = QVBoxLayout() grid = QGridLayout() grid.addWidget(QLabel("Start position(*):"), 0, 0) grid.addWidget(QLabel("row"), 0, 1) grid.addWidget(self.le_roi_start_row, 0, 2) grid.addWidget(QLabel("column"), 0, 3) grid.addWidget(self.le_roi_start_col, 0, 4) grid.addWidget(QLabel("End position(*):"), 1, 0) grid.addWidget(QLabel("row"), 1, 1) grid.addWidget(self.le_roi_end_row, 1, 2) grid.addWidget(QLabel("column"), 1, 3) grid.addWidget(self.le_roi_end_col, 1, 4) vbox.addLayout(grid) vbox.addWidget(self.label_map_size) self.gb_roi.setLayout(vbox) # Widgets for loading mask self.pb_load_mask = QPushButton("Load Mask ...") self.pb_load_mask.clicked.connect(self.pb_load_mask_clicked) self._le_load_mask_default_text = "select 'mask' file" self.le_load_mask = LineEditReadOnly(self._le_load_mask_default_text) # Group box for setting mask self.gb_mask = QGroupBox("Set mask") set_tooltip( self.gb_mask, "Load <b>mask</b> from file. Active pixels in the mask are " "represented by positive integers. If <b>spatial ROI</b> is " "selected, then it is applied to the masked data.", ) self.gb_mask.setCheckable(True) self.gb_mask.toggled.connect(self.gb_mask_toggled) self.gb_mask.setChecked(self._mask_active) hbox = QHBoxLayout() hbox.addWidget(self.pb_load_mask) hbox.addWidget(self.le_load_mask) self.gb_mask.setLayout(hbox) # Yes/No button box self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.button_ok = self.button_box.button(QDialogButtonBox.Ok) self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) vbox = QVBoxLayout() vbox.addWidget(self.gb_roi) vbox.addStretch(1) vbox.addWidget(self.gb_mask) vbox.addStretch(2) vbox.addWidget(self.button_box) self.setLayout(vbox) self._validation_enabled = True self._validate_all_widgets() def _compute_home_directory(self): dir_name = "." if self._default_directory: dir_name = self._default_directory if self._mask_file_path: d, _ = os.path.split(self._mask_file_path) dir_name = d if d else dir_name return dir_name def pb_load_mask_clicked(self): dir_name = self._compute_home_directory() file_name = QFileDialog.getOpenFileName(self, "Load Mask From File", dir_name, "All (*)") file_name = file_name[0] if file_name: self._mask_file_path = file_name self._show_mask_file_path() logger.debug(f"Mask file is selected: '{file_name}'") def gb_roi_toggled(self, state): self._roi_activate(state) def _read_le_roi_value(self, line_edit, v_default): """ Attempt to read value from line edit box as int, return `v_default` if not successful. Parameters ---------- line_edit: QLineEdit reference to QLineEdit object v_default: int default value returned if the value read from edit box is incorrect """ try: val = int(line_edit.text()) if val < 1: raise Exception() except Exception: val = v_default return val def le_roi_start_row_editing_finished(self): self._row_start = self._read_le_roi_value(self.le_roi_start_row, self._row_start + 1) - 1 def le_roi_end_row_editing_finished(self): self._row_end = self._read_le_roi_value(self.le_roi_end_row, self._row_end) def le_roi_start_col_editing_finished(self): self._column_start = self._read_le_roi_value( self.le_roi_start_col, self._column_start + 1) - 1 def le_roi_end_col_editing_finished(self): self._column_end = self._read_le_roi_value(self.le_roi_end_col, self._column_end) def le_roi_start_row_text_changed(self): self._validate_all_widgets() def le_roi_end_row_text_changed(self): self._validate_all_widgets() def le_roi_start_col_text_changed(self): self._validate_all_widgets() def le_roi_end_col_text_changed(self): self._validate_all_widgets() def gb_mask_toggled(self, state): self._mask_file_activate(state) def _validate_all_widgets(self): """ Validate the values and state of all widgets, update the 'valid' state of the widgets and enable/disable Ok button. """ if not self._validation_enabled: return # Check if all fields have valid input values def _check_valid_input(line_edit, flag_valid): val = self._read_le_roi_value(line_edit, -1) state = val > 0 line_edit.setValid(state) flag_valid = flag_valid if state else False return val, flag_valid # Set all line edits to 'valid' state self.le_roi_start_row.setValid(True) self.le_roi_end_row.setValid(True) self.le_roi_start_col.setValid(True) self.le_roi_end_col.setValid(True) self.le_load_mask.setValid(True) flag_valid = True if self._roi_active: # Perform the following checks only if ROI group is active rs, flag_valid = _check_valid_input(self.le_roi_start_row, flag_valid) re, flag_valid = _check_valid_input(self.le_roi_end_row, flag_valid) cs, flag_valid = _check_valid_input(self.le_roi_start_col, flag_valid) ce, flag_valid = _check_valid_input(self.le_roi_end_col, flag_valid) # Check if start if (rs > 0) and (re > 0) and (rs > re): self.le_roi_start_row.setValid(False) self.le_roi_end_row.setValid(False) flag_valid = False if (cs > 0) and (ce > 0) and (cs > ce): self.le_roi_start_col.setValid(False) self.le_roi_end_col.setValid(False) flag_valid = False if self._mask_active: if not self._mask_file_path: self.le_load_mask.setValid(False) flag_valid = False self.button_ok.setEnabled(flag_valid) def set_image_size(self, *, n_rows, n_columns): """ Set the image size. Image size is used to for input validation. When image size is set, the selection is reset to cover the whole image. Parameters ---------- n_rows: int The number of rows in the image: (1..) n_columns: int The number of columns in the image: (1..) """ if n_rows < 1 or n_columns < 1: raise ValueError( "DialogLoadMask: image size have zero rows or zero columns: " f"n_rows={n_rows} n_columns={n_columns}. " "Report the error to the development team.") self._n_rows = n_rows self._n_columns = n_columns self._row_start = 0 self._row_end = n_rows self._column_start = 0 self._column_end = n_columns self._show_selection(True) self._validate_all_widgets() self.validator_rows.setTop(n_rows) self.validator_cols.setTop(n_columns) # Set label self.label_map_size.setText( f"{self._text_map_size_base}{self._n_rows} rows, {self._n_columns} columns." ) def _show_selection(self, visible): """visible: True - show values, False - hide values""" def _show_number(l_edit, value): if value > 0: l_edit.setText(f"{value}") else: # This would typically mean incorrect initialization of the dialog box l_edit.setText("") _show_number(self.le_roi_start_row, self._row_start + 1) _show_number(self.le_roi_start_col, self._column_start + 1) _show_number(self.le_roi_end_row, self._row_end) _show_number(self.le_roi_end_col, self._column_end) def set_roi(self, *, row_start, column_start, row_end, column_end): """ Set the values of fields that define selection of the image region. First set the image size (`set_image_size()`) and then set the selection. Parameters ---------- row_start: int The row number of the first pixel in the selection (0..n_rows-1). Negative (-1) - resets value to 0. column_start: int The column number of the first pixel in the selection (0..n_columns-1). Negative (-1) - resets value to 0. row_end: int The row number following the last pixel in the selection (1..n_rows). This row is not included in the selection. Negative (-1) - resets value to n_rows. column_end: int The column number following the last pixel in the selection (1..n_columns). This column is not included in the selection. Negative (-1) - resets value to n_columns. """ # The variables holding the selected region are following Python conventions for the # selections: row_start, column_start are in the range 0..n_rows-1, 0..n_columns-1 # and row_end, column_end are in the range 1..n_rows, 1..n_columns. # The values displayed in the dialog box are just pixels numbers in the range # 1..n_rows, 1..n_columns that define the rectangle in the way intuitive to the user. self._row_start = int( np.clip(row_start, a_min=0, a_max=self._n_rows - 1)) self._column_start = int( np.clip(column_start, a_min=0, a_max=self._n_columns - 1)) def _adjust_last_index(index, n_elements): if index < 0: index = n_elements index = int(np.clip(index, 1, n_elements)) return index self._row_end = _adjust_last_index(row_end, self._n_rows) self._column_end = _adjust_last_index(column_end, self._n_columns) self._show_selection(self._roi_active) self._validate_all_widgets() def _roi_activate(self, state): self._roi_active = state self._show_selection(state) self._validate_all_widgets() def set_roi_active(self, state): self._roi_activate(state) self.gb_roi.setChecked(self._roi_active) def get_roi(self): return self._row_start, self._column_start, self._row_end, self._column_end def get_roi_active(self): return self._roi_active def _show_mask_file_path(self): fpath = self._mask_file_path if self._mask_file_path else self._le_load_mask_default_text self.le_load_mask.setText(fpath) self._validate_all_widgets() def _mask_file_activate(self, state): self._mask_active = state self._show_mask_file_path() self._validate_all_widgets() def set_mask_file_active(self, state): self._mask_file_activate(state) self.gb_mask.setChecked(self._mask_active) def get_mask_file_active(self): return self._mask_active def set_mask_file_path(self, fpath): self._mask_file_path = fpath self._show_mask_file_path() def get_mask_file_path(self): return self._mask_file_path def set_default_directory(self, dir_name): self._default_directory = dir_name def get_default_directory(self): return self._default_directory
def initialize_content(self): """ Initialize content/UI """ # Initial values for combo boxes # Combo boxes self._content.saveas_combo.setCurrentIndex(1) self._content.unit_combo.setCurrentIndex(1) self._content.bintype_combo.setCurrentIndex(1) # Radio buttons self._content.disablevancorr_chkbox.setChecked(False) # Check boxes self._content.usebin_button.setChecked(True) self._content.resamplex_button.setChecked(False) self._content.disablebkgdcorr_chkbox.setChecked(False) self._content.disablevancorr_chkbox.setChecked(False) self._content.disablevanbkgdcorr_chkbox.setChecked(False) # Label if self._instrument_name is not False: self._content.label.setText('Instrument: %s' % self._instrument_name.upper()) else: self._content.label.setText( 'Instrument has not been set up. You may not launch correctly.' ) # Enable disable if self._instrument_name.lower().startswith('nom') is False: self._content.lineEdit_expIniFile.setEnabled(False) self._content.pushButton_browseExpIniFile.setEnabled(False) else: self._content.lineEdit_expIniFile.setEnabled(True) self._content.pushButton_browseExpIniFile.setEnabled(True) # Line edit self._content.emptyrun_edit.setEnabled(True) self._content.vanrun_edit.setEnabled(True) self._content.vanbkgdrun_edit.setEnabled(True) self._content.resamplex_edit.setEnabled(False) # Constraints/Validator expression = r'[\d,-]*' iv0 = generateRegExpValidator(self._content.emptyrun_edit, expression) self._content.emptyrun_edit.setValidator(iv0) iv1 = generateRegExpValidator(self._content.vanrun_edit, expression) self._content.vanrun_edit.setValidator(iv1) iv3 = generateRegExpValidator(self._content.vanbkgdrun_edit, expression) self._content.vanbkgdrun_edit.setValidator(iv3) siv = QIntValidator(self._content.resamplex_edit) siv.setBottom(0) self._content.resamplex_edit.setValidator(siv) # Float/Double fiv = QDoubleValidator(self._content.binning_edit) self._content.binning_edit.setValidator(fiv) # Default states # self._handle_tzero_guess(self._content.use_ei_guess_chkbox.isChecked()) # Connections from action/event to function to handle self._content.calfile_browse.clicked.connect(self._calfile_browse) self._content.charfile_browse.clicked.connect(self._charfile_browse) self._content.groupfile_browse.clicked.connect(self._groupfile_browse) self._content.pushButton_browseExpIniFile.clicked.connect( self.do_browse_ini_file) self._content.outputdir_browse.clicked.connect(self._outputdir_browse) self._content.binning_edit.textChanged.connect(self._binvalue_edit) self._content.bintype_combo.currentIndexChanged.connect( self._bintype_process) self._content.disablebkgdcorr_chkbox.clicked.connect( self._disablebkgdcorr_clicked) self._content.disablevancorr_chkbox.clicked.connect( self._disablevancorr_clicked) self._content.disablevanbkgdcorr_chkbox.clicked.connect( self._disablevanbkgdcorr_clicked) self._content.usebin_button.clicked.connect(self._usebin_clicked) self._content.resamplex_button.clicked.connect(self._resamplex_clicked) self._content.help_button.clicked.connect(self._show_help) # mutex for whether to update the linear/log drop-down self._content._binning_edit_mutex = False
def __init__(self, parent, text): QWidget.__init__(self, parent) self.text_editor = QTextEdit(self) self.text_editor.setText(text) self.text_editor.setReadOnly(True) # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) data_btn = QRadioButton(_("data")) data_btn.setChecked(True) self._as_data = True type_layout.addWidget(data_btn) code_btn = QRadioButton(_("code")) self._as_code = False type_layout.addWidget(code_btn) txt_btn = QRadioButton(_("text")) type_layout.addWidget(txt_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) # Opts frame grid_layout = QGridLayout() grid_layout.setSpacing(0) col_label = QLabel(_("Column separator:")) grid_layout.addWidget(col_label, 0, 0) col_w = QWidget() col_btn_layout = QHBoxLayout() self.tab_btn = QRadioButton(_("Tab")) self.tab_btn.setChecked(False) col_btn_layout.addWidget(self.tab_btn) self.ws_btn = QRadioButton(_("Whitespace")) self.ws_btn.setChecked(False) col_btn_layout.addWidget(self.ws_btn) other_btn_col = QRadioButton(_("other")) other_btn_col.setChecked(True) col_btn_layout.addWidget(other_btn_col) col_w.setLayout(col_btn_layout) grid_layout.addWidget(col_w, 0, 1) self.line_edt = QLineEdit(",") self.line_edt.setMaximumWidth(30) self.line_edt.setEnabled(True) other_btn_col.toggled.connect(self.line_edt.setEnabled) grid_layout.addWidget(self.line_edt, 0, 2) row_label = QLabel(_("Row separator:")) grid_layout.addWidget(row_label, 1, 0) row_w = QWidget() row_btn_layout = QHBoxLayout() self.eol_btn = QRadioButton(_("EOL")) self.eol_btn.setChecked(True) row_btn_layout.addWidget(self.eol_btn) other_btn_row = QRadioButton(_("other")) row_btn_layout.addWidget(other_btn_row) row_w.setLayout(row_btn_layout) grid_layout.addWidget(row_w, 1, 1) self.line_edt_row = QLineEdit(";") self.line_edt_row.setMaximumWidth(30) self.line_edt_row.setEnabled(False) other_btn_row.toggled.connect(self.line_edt_row.setEnabled) grid_layout.addWidget(self.line_edt_row, 1, 2) grid_layout.setRowMinimumHeight(2, 15) other_group = QGroupBox(_("Additional options")) other_layout = QGridLayout() other_group.setLayout(other_layout) skiprows_label = QLabel(_("Skip rows:")) other_layout.addWidget(skiprows_label, 0, 0) self.skiprows_edt = QLineEdit('0') self.skiprows_edt.setMaximumWidth(30) intvalid = QIntValidator(0, len(to_text_string(text).splitlines()), self.skiprows_edt) self.skiprows_edt.setValidator(intvalid) other_layout.addWidget(self.skiprows_edt, 0, 1) other_layout.setColumnMinimumWidth(2, 5) comments_label = QLabel(_("Comments:")) other_layout.addWidget(comments_label, 0, 3) self.comments_edt = QLineEdit('#') self.comments_edt.setMaximumWidth(30) other_layout.addWidget(self.comments_edt, 0, 4) self.trnsp_box = QCheckBox(_("Transpose")) #self.trnsp_box.setEnabled(False) other_layout.addWidget(self.trnsp_box, 1, 0, 2, 0) grid_layout.addWidget(other_group, 3, 0, 2, 0) opts_frame = QFrame() opts_frame.setLayout(grid_layout) data_btn.toggled.connect(opts_frame.setEnabled) data_btn.toggled.connect(self.set_as_data) code_btn.toggled.connect(self.set_as_code) # self.connect(txt_btn, SIGNAL("toggled(bool)"), # self, SLOT("is_text(bool)")) # Final layout layout = QVBoxLayout() layout.addWidget(type_frame) layout.addWidget(self.text_editor) layout.addWidget(opts_frame) self.setLayout(layout)
def initialize_content(self): """ Initialize content/UI """ # Initial value # combo-boxes self._content.timeunit_combo.setCurrentIndex(0) self._content.valuechange_combo.setCurrentIndex(0) self._content.logbound_combo.setCurrentIndex(0) self._content.log_name_combo.clear() # check-boxes self._content.timefilter_checkBox.setChecked(False) self._content.logvaluefilter_checkBox.setChecked(False) # disable some input self._content.logname_edit.setEnabled(False) self._content.logminvalue_edit.setEnabled(False) self._content.logmaxvalue_edit.setEnabled(False) self._content.logintervalvalue_edit.setEnabled(False) self._content.valuechange_combo.setEnabled(False) self._content.logtol_edit.setEnabled(False) self._content.timetol_edit.setEnabled(False) self._content.logbound_combo.setEnabled(False) boolvalue = False self._content.timintervallength_edit.setEnabled(boolvalue) self._content.timeunit_combo.setEnabled(boolvalue) # radio buttons # self._content.usesize_radiob.setChecked(True) # Constraints/Validator # integers # iv0 = QIntValidator(self._content.numtimeinterval_edit) # iv0.setBottom(0) # self._content.numtimeinterval_edit.setValidator(iv0) iv1 = QIntValidator(self._content.run_number_edit) iv1.setBottom(0) self._content.run_number_edit.setValidator(iv1) # floats dv0 = QDoubleValidator(self._content.starttime_edit) dv0.setBottom(0.) self._content.starttime_edit.setValidator(dv0) dv1 = QDoubleValidator(self._content.stoptime_edit) dv1.setBottom(0.) self._content.stoptime_edit.setValidator(dv1) dv2 = QDoubleValidator(self._content.timintervallength_edit) dv2.setBottom(0.) self._content.timintervallength_edit.setValidator(dv2) # Default states # Connections from action/event to function to handle self._content.timefilter_checkBox.stateChanged.connect(self._filterbytime_statechanged) self._content.logvaluefilter_checkBox.stateChanged.connect(self._filterbylogvalue_statechanged) self._content.load_button.clicked.connect(self._run_number_changed) self._content.run_number_edit.returnPressed.connect(self._run_number_changed) self._content.plot_log_button.clicked.connect(self._plot_log_clicked) self._content.syn_logname_button.clicked.connect(self._sync_logname_clicked) self._content.help_button.clicked.connect(self._show_help) # Validated widgets # self._connect_validated_lineedit(self._content.sample_edit) return
def initialize_content(self): """ Initialize content/UI """ # Initial values for combo boxes # Combo boxes self._content.saveas_combo.setCurrentIndex(1) self._content.unit_combo.setCurrentIndex(1) self._content.bintype_combo.setCurrentIndex(1) # Radio buttons self._content.disablevancorr_chkbox.setChecked(False) # Check boxes self._content.usebin_button.setChecked(True) self._content.resamplex_button.setChecked(False) self._content.disablebkgdcorr_chkbox.setChecked(False) self._content.disablevancorr_chkbox.setChecked(False) self._content.disablevanbkgdcorr_chkbox.setChecked(False) # Label if self._instrument_name is not False: self._content.label.setText('Instrument: %s' % self._instrument_name.upper()) else: self._content.label.setText('Instrument has not been set up. You may not launch correctly.') # Enable disable if self._instrument_name.lower().startswith('nom') is False: self._content.lineEdit_expIniFile.setEnabled(False) self._content.pushButton_browseExpIniFile.setEnabled(False) else: self._content.lineEdit_expIniFile.setEnabled(True) self._content.pushButton_browseExpIniFile.setEnabled(True) # Line edit self._content.emptyrun_edit.setEnabled(True) self._content.vanrun_edit.setEnabled(True) self._content.vanbkgdrun_edit.setEnabled(True) self._content.resamplex_edit.setEnabled(False) # Constraints/Validator expression = r'[\d,-]*' iv0 = generateRegExpValidator(self._content.emptyrun_edit, expression) self._content.emptyrun_edit.setValidator(iv0) iv1 = generateRegExpValidator(self._content.vanrun_edit, expression) self._content.vanrun_edit.setValidator(iv1) iv3 = generateRegExpValidator(self._content.vanbkgdrun_edit, expression) self._content.vanbkgdrun_edit.setValidator(iv3) siv = QIntValidator(self._content.resamplex_edit) siv.setBottom(0) self._content.resamplex_edit.setValidator(siv) # Float/Double fiv = QDoubleValidator(self._content.binning_edit) self._content.binning_edit.setValidator(fiv) # Default states # self._handle_tzero_guess(self._content.use_ei_guess_chkbox.isChecked()) # Connections from action/event to function to handle self._content.calfile_browse.clicked.connect(self._calfile_browse) self._content.charfile_browse.clicked.connect(self._charfile_browse) self._content.groupfile_browse.clicked.connect(self._groupfile_browse) self._content.pushButton_browseExpIniFile.clicked.connect(self.do_browse_ini_file) self._content.outputdir_browse.clicked.connect(self._outputdir_browse) self._content.binning_edit.textChanged.connect(self._binvalue_edit) self._content.bintype_combo.currentIndexChanged.connect(self._bintype_process) self._content.disablebkgdcorr_chkbox.clicked.connect(self._disablebkgdcorr_clicked) self._content.disablevancorr_chkbox.clicked.connect(self._disablevancorr_clicked) self._content.disablevanbkgdcorr_chkbox.clicked.connect(self._disablevanbkgdcorr_clicked) self._content.usebin_button.clicked.connect(self._usebin_clicked) self._content.resamplex_button.clicked.connect(self._resamplex_clicked) self._content.help_button.clicked.connect(self._show_help) # mutex for whether to update the linear/log drop-down self._content._binning_edit_mutex = False
def setup_ui(self): self.main_layout = QGridLayout() self.setLayout(self.main_layout) # add toolbar self.toolbar = QToolBar() self.main_layout.setMenuBar(self.toolbar) # create the tree view layout and add/remove buttons self.tree_view_layout = QVBoxLayout() self.tree_view = PyDMAlarmTree(self, config_name="UNITITLED", edit_mode=True) self.tree_view.setEditTriggers(QAbstractItemView.DoubleClicked) self.tree_view.setSelectionMode(QAbstractItemView.SingleSelection) self.tree_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.tree_view.setHeaderHidden(True) # Drag/drop self.tree_view.setDragDropMode(QAbstractItemView.InternalMove) self.tree_view.setDragEnabled(True) self.tree_view.setAcceptDrops(True) # view sizing self.tree_view.setColumnWidth(0, 160) self.tree_view.setColumnWidth(1, 160) self.tree_view.setColumnWidth(2, 160) # lable for tree view configuration_indicator = QLabel("Configuration:") self.tree_label = QLineEdit("Untitled") self.tree_label_layout = QHBoxLayout() self.tree_label_layout.addWidget(configuration_indicator) self.tree_label_layout.addWidget(self.tree_label) self.tree_view_layout.addLayout(self.tree_label_layout) self.tree_view_layout.addWidget(self.tree_view) # add/ remove buttons self.add_remove_layout = QHBoxLayout() spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.add_remove_layout.addItem(spacer) self.add_button = QPushButton("New", self) self.add_remove_layout.addWidget(self.add_button) self.remove_button = QPushButton("Remove", self) self.add_remove_layout.addWidget(self.remove_button) self.tree_view_layout.addLayout(self.add_remove_layout) # add the tree view to the window self.main_layout.addLayout(self.tree_view_layout, 0, 0) self.property_layout = QVBoxLayout() self.property_layout.addWidget(QLabel("Alarm Properties")) # crate property view self.property_data_layout = QStackedLayout() self.property_layout.addLayout(self.property_data_layout) self.property_widget_config = QWidget() self.property_widget_config.setWindowTitle("config") # create group widget self.property_widget_group = QWidget() self.property_widget_group.setWindowTitle("group") self.property_view_layout_group = QGridLayout() # add label self.label_edit_group = QLineEdit() self.label_label_group = QLabel("NAME") # add guidance self.guidance_edit_group = QLineEdit() self.guidance_label_group = QLabel("GUIDANCE") self.property_view_layout_group.addWidget(self.label_label_group, 1, 0) self.property_view_layout_group.addWidget(self.label_edit_group, 1, 1) self.property_view_layout_group.addWidget(self.guidance_label_group, 2, 0) self.property_view_layout_group.addWidget(self.guidance_edit_group, 2, 1) spacer = QSpacerItem(40, 200, QSizePolicy.Expanding, QSizePolicy.Minimum) self.property_view_layout_group.addItem(spacer, 3, 0) self.property_view_layout_group.addItem(spacer, 4, 0) self.property_view_layout_group.addItem(spacer, 5, 0) self.property_view_layout_group.addItem(spacer, 6, 0) self.property_view_layout_group.addItem(spacer, 7, 0) self.property_view_layout_group.addItem(spacer, 8, 0) # create pv widget self.property_widget_pv = QWidget() self.property_widget_pv.setWindowTitle("pv") self.property_view_layout_pv = QGridLayout() # add label self.label_edit_pv = QLineEdit() self.label_label_pv = QLabel("NAME") # add guidance self.guidance_edit_pv = QLineEdit() self.guidance_label_pv = QLabel("GUIDANCE") self.property_view_layout_pv.addWidget(self.label_label_pv, 1, 0) self.property_view_layout_pv.addWidget(self.label_edit_pv, 1, 1, 1, 3) self.property_view_layout_pv.addWidget(self.guidance_label_pv, 2, 0) self.property_view_layout_pv.addWidget(self.guidance_edit_pv, 2, 1, 1, 3) # add description self.description_edit = QLineEdit() self.description_label = QLabel("DESCRIPTION") self.property_view_layout_pv.addWidget(self.description_label, 3, 0) self.property_view_layout_pv.addWidget(self.description_edit, 3, 1, 1, 3) # add delay self.delay_edit = QLineEdit() self.delay_label = QLabel("DELAY") self.property_view_layout_pv.addWidget(self.delay_label, 4, 0) self.property_view_layout_pv.addWidget(self.delay_edit, 4, 1, 1, 3) self.delay_edit.setValidator(QIntValidator()) # add count self.count_edit = QLineEdit() self.count_label = QLabel("COUNT") self.property_view_layout_pv.addWidget(self.count_label, 5, 0) self.property_view_layout_pv.addWidget(self.count_edit, 5, 1, 1, 3) self.count_edit.setValidator(QIntValidator()) # add filter/force pv self.filter_edit = QLineEdit() self.filter_label = QLabel("ENABLING FILTER") self.property_view_layout_pv.addWidget(self.filter_label, 6, 0) self.property_view_layout_pv.addWidget(self.filter_edit, 6, 1, 1, 3) # enabled, latching, annunciating self.enabled_check = QCheckBox("ENABLED") self.annunciating_check = QCheckBox("ANNUNCIATING") self.latching_check = QCheckBox("LATCHING") self.property_view_layout_pv.addWidget(self.enabled_check, 7, 0) self.property_view_layout_pv.addWidget(self.annunciating_check, 7, 1) self.property_view_layout_pv.addWidget(self.latching_check, 7, 2) self.property_view_layout_pv.addItem(spacer, 8, 0) # create save button self.button_box = QDialogButtonBox(self) self.button_box.setOrientation(Qt.Horizontal) self.button_box.addButton("Save Properties", QDialogButtonBox.AcceptRole) self.property_layout.addWidget(self.button_box) # self.property_layout.addLayout(self.property_view_layout) self.property_widget_pv.setLayout(self.property_view_layout_pv) self.property_widget_group.setLayout(self.property_view_layout_group) self.property_data_layout.addWidget(self.property_widget_config) self.property_data_layout.addWidget(self.property_widget_pv) self.property_data_layout.addWidget(self.property_widget_group) self.main_layout.addLayout(self.property_layout, 0, 1) self.setWindowTitle("Alarm Tree Editor") self.tree_view.expandAll()
def initialize_content(self): # Validators self._summary.detector_offset_edit.setValidator( QDoubleValidator(self._summary.detector_offset_edit)) self._summary.sample_dist_edit.setValidator( QDoubleValidator(self._summary.sample_dist_edit)) self._summary.sample_si_dist_edit.setValidator( QDoubleValidator(self._summary.sample_si_dist_edit)) self._summary.total_detector_distance_edit.setValidator( QDoubleValidator(self._summary.total_detector_distance_edit)) self._summary.wavelength_edit.setValidator( QDoubleValidator(self._summary.wavelength_edit)) self._summary.wavelength_spread_edit.setValidator( QDoubleValidator(self._summary.wavelength_spread_edit)) self._summary.n_q_bins_edit.setValidator( QIntValidator(self._summary.n_q_bins_edit)) self._summary.n_sub_pix_edit.setValidator( QIntValidator(self._summary.n_sub_pix_edit)) # Event connections self._summary.detector_offset_chk.clicked.connect( self._det_offset_clicked) self._summary.sample_dist_chk.clicked.connect( self._sample_dist_clicked) self._summary.sample_si_dist_chk.clicked.connect( self._sample_si_dist_clicked) self._summary.total_detector_distance_chk.clicked.connect( self._total_dist_clicked) self._summary.wavelength_chk.clicked.connect(self._wavelength_clicked) self._summary.sample_dist_edit.textChanged.connect( self._update_total_distance) self._summary.sample_si_dist_edit.textChanged.connect( self._update_total_distance) self._summary.detector_offset_edit.textChanged.connect( self._update_total_distance) self._summary.dark_current_check.clicked.connect(self._dark_clicked) self._summary.dark_browse_button.clicked.connect(self._dark_browse) self._summary.dark_plot_button.clicked.connect(self._dark_plot_clicked) self._summary.normalization_none_radio.clicked.connect( self._normalization_clicked) self._summary.normalization_time_radio.clicked.connect( self._normalization_clicked) self._summary.normalization_monitor_radio.clicked.connect( self._normalization_clicked) # Q range self._summary.n_q_bins_edit.setText("100") self._summary.n_sub_pix_edit.setText("1") self._summary.log_binning_radio.clicked.connect( self._summary.align_check.setEnabled) self._summary.scale_edit.setText("1") self._summary.n_wedges_edit.setText("2") self._summary.wedge_angle_edit.setText("30") self._summary.wedge_offset_edit.setText("0") self._summary.instr_name_label.hide() self._dark_clicked(self._summary.dark_current_check.isChecked()) # Mask Connections self._summary.mask_browse_button.clicked.connect( self._mask_browse_clicked) self._summary.mask_plot_button.clicked.connect(self._mask_plot_clicked) self._summary.mask_check.clicked.connect(self._mask_checked) # Absolute scale connections and validators self._summary.scale_edit.setValidator( QDoubleValidator(self._summary.scale_edit)) self._summary.scale_beam_radius_edit.setValidator( QDoubleValidator(self._summary.scale_beam_radius_edit)) self._summary.scale_att_trans_edit.setValidator( QDoubleValidator(self._summary.scale_att_trans_edit)) self._summary.scale_data_browse_button.clicked.connect( self._scale_data_browse) self._summary.scale_data_plot_button.clicked.connect( self._scale_data_plot_clicked) self._summary.beamstop_chk.clicked.connect(self._beamstop_clicked) self._summary.scale_chk.clicked.connect(self._scale_clicked) self._scale_clicked(self._summary.scale_chk.isChecked()) # If we are not in debug/expert mode, hide some advanced options if not self._settings.debug: self._summary.mask_side_layout.deleteLater() self._summary.mask_side_label.hide() self._summary.mask_side_none_radio.hide() self._summary.mask_side_front_radio.hide() self._summary.mask_side_back_radio.hide() if not self._has_instrument_view: self._summary.dark_plot_button.hide() self._summary.scale_data_plot_button.hide()
def _update_validator(self): self._validator = QIntValidator(self._min_value, self._max_value, self) self._lineedit.setValidator(self._validator)
def __init__(self, parent=None): super(IntLineEdit, self).__init__(parent) self._default_value = 0 self.setValidator(QIntValidator())
def __init__(self, parent, new_size, old_size, text="", keep_original_size=False): QDialog.__init__(self, parent) win32_fix_title_bar_background(self) intfunc = lambda tup: [int(val) for val in tup] if intfunc(new_size) == intfunc(old_size): self.keep_original_size = True else: self.keep_original_size = keep_original_size self.width, self.height = new_size self.old_width, self.old_height = old_size self.ratio = self.width / self.height layout = QVBoxLayout() self.setLayout(layout) formlayout = QFormLayout() layout.addLayout(formlayout) if text: label = QLabel(text) label.setAlignment(Qt.AlignHCenter) formlayout.addRow(label) self.w_edit = w_edit = QLineEdit(self) w_valid = QIntValidator(w_edit) w_valid.setBottom(1) w_edit.setValidator(w_valid) self.h_edit = h_edit = QLineEdit(self) h_valid = QIntValidator(h_edit) h_valid.setBottom(1) h_edit.setValidator(h_valid) zbox = QCheckBox(_("Original size"), self) formlayout.addRow(_("Width (pixels)"), w_edit) formlayout.addRow(_("Height (pixels)"), h_edit) formlayout.addRow("", zbox) formlayout.addRow(_("Original size:"), QLabel("%d x %d" % old_size)) self.z_label = QLabel() formlayout.addRow(_("Zoom factor:"), self.z_label) # Button box self.bbox = bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) layout.addWidget(bbox) self.w_edit.setText(str(self.width)) self.h_edit.setText(str(self.height)) self.update_widgets() self.setWindowTitle(_("Resize")) w_edit.textChanged.connect(self.width_changed) h_edit.textChanged.connect(self.height_changed) zbox.toggled.connect(self.toggled_no_zoom) zbox.setChecked(self.keep_original_size)