def __init__(self, canvas, axes, axis_id):
        """

        :param canvas: A reference to the target canvas
        :param axes: The axes object holding the properties to be edited
        :param axis_id: A string ID for the axis
        """
        super(AxisEditor, self).__init__('axiseditor.ui', canvas)
        # suppress errors
        self.ui.errors.hide()
        # Ensure that only floats can be entered
        self.ui.editor_min.setValidator(QDoubleValidator())
        self.ui.editor_max.setValidator(QDoubleValidator())

        self.axes = axes
        self.axis_id = axis_id
        self.lim_setter = getattr(axes, 'set_{}lim'.format(axis_id))
        self.scale_setter = getattr(axes, 'set_{}scale'.format(axis_id))
        self.linthresholdkw = 'linthres' + axis_id
        # Grid has no direct accessor from the axes
        axis = axes.xaxis if axis_id == 'x' else axes.yaxis

        memento = AxisEditorModel()
        self._momento = memento
        memento.min, memento.max = getattr(axes, 'get_{}lim'.format(axis_id))()
        memento.log = getattr(axes,
                              'get_{}scale'.format(axis_id))() != 'linear'
        memento.grid = axis.majorTicks[0].gridOn

        self._fill(memento)
    def __init__(self, canvas, axes, axis_id):
        """

        :param canvas: A reference to the target canvas
        :param axes: The axes object holding the properties to be edited
        :param axis_id: A string ID for the axis
        """
        super(AxisEditor, self).__init__('axiseditor.ui', canvas)
        # suppress errors
        self.ui.errors.hide()
        # Ensure that only floats can be entered
        self.ui.editor_min.setValidator(QDoubleValidator())
        self.ui.editor_max.setValidator(QDoubleValidator())
        if figure_type(
                canvas.figure) in [FigureType.Surface, FigureType.Wireframe]:
            self.ui.logBox.hide()
            self.ui.gridBox.hide()
        self.ui.editor_format.addItem('Decimal Format')
        self.ui.editor_format.addItem('Scientific Format')
        self.axes = axes
        self.axis_id = axis_id
        self.lim_getter = getattr(axes, 'get_{}lim'.format(axis_id))

        if isinstance(axes, Axes3D):
            self.lim_setter = getattr(axes, 'set_{}lim3d'.format(axis_id))
        else:
            self.lim_setter = getattr(axes, 'set_{}lim'.format(axis_id))

        self.scale_setter = getattr(axes, 'set_{}scale'.format(axis_id))
        self.nonposkw = 'nonpos' + axis_id
        # Grid has no direct accessor from the axes
        self.axis = axes.xaxis if axis_id == 'x' else axes.yaxis
Example #3
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self,parent)
        self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
        self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
        self.ui.totalFlightPathInput.setValidator(QDoubleValidator(self.ui.totalFlightPathInput))
        self.ui.scatteringAngleInput.setValidator(QDoubleValidator(self.ui.scatteringAngleInput))
        self.ui.convertButton.clicked.connect(self.convert)
        self.ui.helpButton.clicked.connect(self.helpClicked)
        self.ui.inputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
        self.ui.outputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
        self.setInstrumentInputs()

        ##defaults
        self.flightpath = -1.0
        self.Theta = -1.0
        self.output = 0.0

        #help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        import mantid
        self.mantidplot_name='TOF Converter'
        self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
        version = ".".join(mantid.__version__.split(".")[:2])
        self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/TOF Converter.html'
        self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/TOF Converter.html'

        try:
            import mantid
            #register startup
            mantid.UsageService.registerFeatureUsage("Interface","TofConverter",False)
        except ImportError:
            pass
Example #4
0
    def initialize_content(self):
        """
            Declare the validators and event connections for the
            widgets loaded through the .ui file.
        """
        # Validators
        self._content.spreader_trans_edit.setValidator(
            QDoubleValidator(self._content.spreader_trans_edit))
        self._content.spreader_trans_spread_edit.setValidator(
            QDoubleValidator(self._content.spreader_trans_spread_edit))

        # Connections
        self._content.sample_scatt_browse.clicked.connect(
            self._sample_scatt_browse)
        self._content.sample_spread_browse.clicked.connect(
            self._sample_spread_browse)
        self._content.direct_scatt_browse.clicked.connect(
            self._direct_scatt_browse)
        self._content.direct_spread_browse.clicked.connect(
            self._direct_spread_browse)

        self._content.sample_scatt_plot.clicked.connect(
            self._sample_scatt_plot_clicked)
        self._content.sample_spread_plot.clicked.connect(
            self._sample_spread_plot_clicked)
        self._content.direct_scatt_plot.clicked.connect(
            self._direct_scatt_plot_clicked)
        self._content.direct_spread_plot.clicked.connect(
            self._direct_spread_plot_clicked)

        if not self._has_instrument_view:
            self._content.sample_scatt_plot.hide()
            self._content.sample_spread_plot.hide()
            self._content.direct_scatt_plot.hide()
            self._content.direct_spread_plot.hide()
Example #5
0
    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)
Example #6
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
        self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
        self.ui.totalFlightPathInput.setValidator(
            QDoubleValidator(self.ui.totalFlightPathInput))
        self.ui.scatteringAngleInput.setValidator(
            QDoubleValidator(self.ui.scatteringAngleInput))
        self.ui.convertButton.clicked.connect(self.convert)
        self.ui.helpButton.clicked.connect(self.helpClicked)
        self.ui.inputUnits.currentIndexChanged.connect(
            self.setInstrumentInputs)
        self.ui.outputUnits.currentIndexChanged.connect(
            self.setInstrumentInputs)
        self.setInstrumentInputs()

        ##defaults
        self.flightpath = -1.0
        self.Theta = -1.0
        self.output = 0.0

        try:
            import mantid
            #register startup
            mantid.UsageService.registerFeatureUsage("Interface",
                                                     "TofConverter", False)
        except ImportError:
            pass
Example #7
0
    def __init__(self, canvas, axes, axis_id):
        """

        :param canvas: A reference to the target canvas
        :param axes: The axes object holding the properties to be edited
        :param axis_id: A string ID for the axis
        """
        super(AxisEditor, self).__init__('axiseditor.ui', canvas)
        # suppress errors
        self.ui.errors.hide()
        # Ensure that only floats can be entered
        self.ui.editor_min.setValidator(QDoubleValidator())
        self.ui.editor_max.setValidator(QDoubleValidator())
        if figure_type(canvas.figure) in [
                FigureType.Surface, FigureType.Wireframe, FigureType.Mesh
        ]:
            self.ui.logBox.hide()
            self.ui.gridBox.hide()
        self.ui.editor_format.addItem(DECIMAL_FORMAT)
        self.ui.editor_format.addItem(SCIENTIFIC_FORMAT)
        self.axes = axes
        self.axis_id = axis_id
        self.lim_getter = getattr(axes, 'get_{}lim'.format(axis_id))

        if isinstance(axes, Axes3D):
            self.lim_setter = getattr(axes, 'set_{}lim3d'.format(axis_id))
        else:
            self.lim_setter = getattr(axes, 'set_{}lim'.format(axis_id))

        self.scale_setter = getattr(axes, 'set_{}scale'.format(axis_id))
        self.nonposkw = 'nonpos' + axis_id
        # Store the axis for attributes that can't be directly accessed
        # from axes object (e.g. grid and tick parameters).
        self.axis = getattr(axes, '{}axis'.format(axis_id))
    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)
Example #9
0
    def _setup_action_buttons(self):
        self.pb_remove_rel = QPushButton("Remove Rel.Int.(%) <")
        self.pb_remove_rel.clicked.connect(self.pb_remove_rel_clicked)

        self.le_remove_rel = LineEditExtended("")
        self._validator_le_remove_rel = QDoubleValidator()
        self._validator_le_remove_rel.setBottom(0.01)  # Some small number
        self._validator_le_remove_rel.setTop(100.0)
        self.le_remove_rel.setText(
            self._format_threshold(self._remove_peak_threshold))
        self._update_le_remove_rel_state()
        self.le_remove_rel.textChanged.connect(self.le_remove_rel_text_changed)
        self.le_remove_rel.editingFinished.connect(
            self.le_remove_rel_editing_finished)

        self.pb_remove_unchecked = QPushButton("Remove Unchecked Lines")
        self.pb_remove_unchecked.clicked.connect(
            self.pb_remove_unchecked_clicked)

        hbox = QHBoxLayout()
        hbox.addWidget(self.pb_remove_rel)
        hbox.addWidget(self.le_remove_rel)
        hbox.addStretch(1)
        hbox.addWidget(self.pb_remove_unchecked)

        return hbox
    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)
Example #11
0
    def initialize_content(self):
        # Constraints
        for widget in [
                self._content.ei_edit,
                self._content.van_mass_edit,
                self._content.sample_mass_edit,
                self._content.sample_rmm_edit,
                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,
        ]:

            dvp = QDoubleValidator(widget)
            dvp.setBottom(0.0)
            widget.setValidator(dvp)

        # Connections
        self._content.absunits_van_browse.clicked.connect(
            self._absunits_van_browse)
        self._content.absunits_detvan_browse.clicked.connect(
            self._absunits_detvan_browse)
        self._content.grouping_file_browse.clicked.connect(
            self._grouping_file_browse)
Example #12
0
    def initialize_content(self):
        """
            Declare the validators and event connections for the
            widgets loaded through the .ui file.
        """
        # Validators
        self._content.transmission_edit.setValidator(
            QDoubleValidator(self._content.transmission_edit))
        self._content.dtransmission_edit.setValidator(
            QDoubleValidator(self._content.dtransmission_edit))
        self._content.thickness_edit.setValidator(
            QDoubleValidator(self._content.thickness_edit))

        # Connections
        self._content.data_file_browse_button.clicked.connect(
            self._data_file_browse)
        self._content.calculate_chk.clicked.connect(self._calculate_clicked)
        self._content.direct_beam_chk.clicked.connect(self._direct_beam)
        self._content.beam_spreader_chk.clicked.connect(self._beam_spreader)
        self._content.dark_current_button.clicked.connect(
            self._dark_current_browse)

        self._content.data_file_plot_button.clicked.connect(
            self._data_file_plot)
        self._content.dark_current_plot_button.clicked.connect(
            self._dark_plot_clicked)

        if not self._has_instrument_view:
            self._content.dark_current_plot_button.hide()
            self._content.data_file_plot_button.hide()
Example #13
0
    def __init__(self, parent=None, window_flags=None):
        QMainWindow.__init__(self, parent)
        if window_flags:
            self.setWindowFlags(window_flags)
        self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
        self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
        self.ui.totalFlightPathInput.setValidator(
            QDoubleValidator(self.ui.totalFlightPathInput))
        self.ui.scatteringAngleInput.setValidator(
            QDoubleValidator(self.ui.scatteringAngleInput))
        self.ui.convertButton.clicked.connect(self.convert)
        self.ui.helpButton.clicked.connect(self.helpClicked)
        self.ui.inputUnits.currentIndexChanged.connect(
            self.setInstrumentInputs)
        self.ui.outputUnits.currentIndexChanged.connect(
            self.setInstrumentInputs)
        self.setInstrumentInputs()

        ##defaults
        self.flightpath = -1.0
        self.Theta = -1.0
        self.output = 0.0

        #help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        self.mantidplot_name = 'TOF Converter'

        try:
            import mantid
            #register startup
            mantid.UsageService.registerFeatureUsage(
                mantid.kernel.FeatureType.Interface, "TofConverter", False)
        except ImportError:
            pass
Example #14
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self._data = {"name": "", "maxv": 0, "energy": 0, "fwhm": 0}

        self.setWindowTitle("Edit User-Defined Peak Parameters")
        self.setMinimumWidth(400)

        self.le_name = LineEditReadOnly()
        set_tooltip(self.le_name, "<b>Name</b> of the user-defined peak.")
        self.le_intensity = LineEditExtended()
        set_tooltip(
            self.le_intensity,
            "Peak <b>intensity</b>. Typically it is not necessary to set the "
            "intensity precisely, since it is refined during fitting of total "
            "spectrum.",
        )
        self.le_energy = LineEditExtended()
        set_tooltip(self.le_energy, "<b>Energy</b> (keV) of the center of the user-defined peak.")
        self.le_fwhm = LineEditExtended()
        set_tooltip(self.le_fwhm, "<b>FWHM</b> (in keV) of the user-defined peak.")

        self._validator = QDoubleValidator()

        vbox = QVBoxLayout()

        grid = QGridLayout()
        grid.addWidget(QLabel("Peak name:"), 0, 0)
        grid.addWidget(self.le_name, 0, 1)
        grid.addWidget(QLabel("Energy, keV"), 1, 0)
        grid.addWidget(self.le_energy, 1, 1)
        grid.addWidget(QLabel("Intensity:"), 2, 0)
        grid.addWidget(self.le_intensity, 2, 1)
        grid.addWidget(QLabel("FWHM, keV"), 3, 0)
        grid.addWidget(self.le_fwhm, 3, 1)
        vbox.addLayout(grid)

        button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        button_box.button(QDialogButtonBox.Cancel).setDefault(True)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self.pb_ok = button_box.button(QDialogButtonBox.Ok)

        vbox.addWidget(button_box)

        self.setLayout(vbox)

        self.le_intensity.editingFinished.connect(self.le_intensity_editing_finished)
        self.le_energy.editingFinished.connect(self.le_energy_editing_finished)
        self.le_fwhm.editingFinished.connect(self.le_fwhm_editing_finished)

        self.le_intensity.textChanged.connect(self.le_intensity_text_changed)
        self.le_energy.textChanged.connect(self.le_energy_text_changed)
        self.le_fwhm.textChanged.connect(self.le_fwhm_text_changed)
Example #15
0
    def __init__(self, parent=None):
        self._parent = parent
        super().__init__(parent)
        self.setTitle("Define dâ‚€")
        layout = QVBoxLayout()
        self.d0_grid_switch = QComboBox()
        self.d0_grid_switch.addItems(["Constant", "Field"])
        self.d0_grid_switch.currentTextChanged.connect(self.set_case)
        layout.addWidget(self.d0_grid_switch)
        self.d0_box = QWidget()
        d0_box_layout = QHBoxLayout()
        d0_box_layout.addWidget(QLabel("dâ‚€"))
        validator = QDoubleValidator()
        validator.setBottom(0)
        self.d0 = QLineEdit()
        self.d0.setValidator(validator)
        self.d0.editingFinished.connect(self.update_d0)
        d0_box_layout.addWidget(self.d0)
        d0_box_layout.addWidget(QLabel("Δd₀"))
        self.d0e = QLineEdit()
        self.d0e.setValidator(validator)
        self.d0e.editingFinished.connect(self.update_d0)
        d0_box_layout.addWidget(self.d0e)
        self.d0_box.setLayout(d0_box_layout)
        layout.addWidget(self.d0_box)

        load_save = QWidget()
        load_save_layout = QHBoxLayout()
        self.load_grid = QPushButton("Load dâ‚€ Grid")
        self.load_grid.clicked.connect(self.load_d0_field)
        load_save_layout.addWidget(self.load_grid)
        self.save_grid = QPushButton("Save dâ‚€ Grid")
        self.save_grid.clicked.connect(self.save_d0_field)
        load_save_layout.addWidget(self.save_grid)
        load_save.setLayout(load_save_layout)
        layout.addWidget(load_save)
        self.d0_grid = QTableWidget()
        self.d0_grid.setColumnCount(5)
        self.d0_grid.setColumnWidth(0, 60)
        self.d0_grid.setColumnWidth(1, 60)
        self.d0_grid.setColumnWidth(2, 60)
        self.d0_grid.setColumnWidth(3, 60)
        self.d0_grid.verticalHeader().setVisible(False)
        self.d0_grid.horizontalHeader().setStretchLastSection(True)
        self.d0_grid.setHorizontalHeaderLabels(['vx', 'vy', 'vz', "d₀", "Δd₀"])
        spinBoxDelegate = SpinBoxDelegate()
        self.d0_grid.setItemDelegateForColumn(3, spinBoxDelegate)
        self.d0_grid.setItemDelegateForColumn(4, spinBoxDelegate)
        layout.addWidget(self.d0_grid)

        self.setLayout(layout)

        self.set_case('Constant')
Example #16
0
    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)
Example #17
0
    def __init__(self, parent=None):
        super(TopAxisDialog, self).__init__(parent)
        self.ref_wave = 0.0
        self.redshift = 0.0

        # Set validators
        self.line_edit_reference_wavelength.setValidator(QDoubleValidator())
        self.line_edit_redshift.setValidator(QDoubleValidator())

        # Populate options
        self.combo_box_axis_mode.addItems(['Velocity', 'Redshift', 'Pixel'])

        # Setup connections
        self._setup_connections()
        self._on_select(0)
Example #18
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTitle("Mechanical Constants")

        layout = QFormLayout()
        validator = QDoubleValidator()
        validator.setBottom(0)
        self.youngModulus = QLineEdit()
        self.youngModulus.setValidator(validator)
        self.poissonsRatio = QLineEdit()
        self.poissonsRatio.setValidator(validator)
        layout.addRow(QLabel("Young Modulus, E (GPa)"), self.youngModulus)
        layout.addRow(QLabel("Poisson's ratio, ν"), self.poissonsRatio)

        self.setLayout(layout)
Example #19
0
    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)
Example #20
0
    def __init__(self, value='', parent=None, get_pos=None):
        """Helper class to position LineEdits above the slider handle

        Parameters
        ----------
        value : str, optional
            starting value, by default ''
        parent : QRangeSliderPopup, optional
            required for proper label positioning above handle, by default None
        get_pos : callable, optional
            function that returns the position of the appropriate slider handle
            by default None
        """
        super().__init__(value, parent=parent)
        self.fm = QFontMetrics(QFont("", 0))
        self.setObjectName('slice_label')
        self.min_width = 30
        self.max_width = 200
        self.setCursor(Qt.IBeamCursor)
        self.setValidator(QDoubleValidator())
        self.textChanged.connect(self._on_text_changed)
        self._on_text_changed(value)

        self.get_pos = get_pos
        if parent is not None:
            self.min_width = 50
            self.slider = parent.slider
            self.setAlignment(Qt.AlignCenter)
Example #21
0
    def initialize_content(self):
        """
            Declare the validators and event connections for the
            widgets loaded through the .ui file.
        """
        # Validators
        self._content.transmission_edit.setValidator(
            QDoubleValidator(self._content.transmission_edit))
        self._content.dtransmission_edit.setValidator(
            QDoubleValidator(self._content.dtransmission_edit))
        #self._content.thickness_edit.setValidator(QDoubleValidator(self._content.thickness_edit))

        # Connections
        self._content.calculate_trans_chk.clicked.connect(
            self._calculate_clicked)
        self._content.trans_direct_chk.clicked.connect(self._direct_beam)
        self._content.trans_spreader_chk.clicked.connect(self._beam_spreader)
        self._content.background_chk.clicked.connect(self._background_clicked)
        self._content.background_browse.clicked.connect(
            self._background_browse)
        self._content.trans_dark_current_button.clicked.connect(
            self._trans_dark_current_browse)

        self._content.background_plot_button.clicked.connect(
            self._background_plot_clicked)
        self._content.trans_dark_current_plot_button.clicked.connect(
            self._trans_dark_current_plot_clicked)

        # Process transmission option
        if not self.show_transmission:
            self._content.calculate_trans_chk.hide()
            self._content.bck_trans_label.hide()
            self._content.bck_trans_err_label.hide()
            self._content.transmission_edit.hide()
            self._content.dtransmission_edit.hide()
            self._content.calculate_trans_chk.hide()
            self._content.theta_dep_chk.hide()
            self._content.trans_direct_chk.hide()
            self._content.trans_spreader_chk.hide()
            self._content.trans_dark_current_label.hide()
            self._content.trans_dark_current_edit.hide()
            self._content.trans_dark_current_button.hide()

        if not self._has_instrument_view:
            self._content.background_plot_button.hide()
            self._content.trans_dark_current_plot_button.hide()
Example #22
0
 def make_item(val, key=None):
     item = QLineEdit()
     item.setText(str(val))
     item.setValidator(QDoubleValidator(item))
     item.setFrame(False)
     if key:
         item.editingFinished.connect(make_handler(item=item, key=key))
     return item
Example #23
0
 def __init__(self, style=None, parent=None):
     super().__init__(style=style, parent=parent)
     self._number = None
     self._line_edit = QLineEdit()
     self._line_edit.setValidator(QDoubleValidator())
     self._line_edit.setMaximumSize(self._line_edit.sizeHint())
     self._line_edit.textChanged.connect(self.on_text_edited)
     self._line_edit.setText("0.0")
Example #24
0
 def createEditor(self, parent, option, index):
     """Create editor widget"""
     model = index.model()
     value = model.get_value(index)
     if model._data.dtype.name == "bool":
         value = not value
         model.setData(index, to_qvariant(value))
         return
     elif value is not np.ma.masked:
         editor = QLineEdit(parent)
         editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
         editor.setAlignment(Qt.AlignCenter)
         if is_number(self.dtype):
             validator = QDoubleValidator(editor)
             validator.setLocale(QLocale('C'))
             editor.setValidator(validator)
         editor.returnPressed.connect(self.commitAndCloseEditor)
         return editor
Example #25
0
 def createEditor(self, parent, option, index):
     """Create editor widget"""
     model = index.model()
     value = model.get_value(index)
     if model._data.dtype.name == "bool":
         value = not value
         model.setData(index, to_qvariant(value))
         return
     elif value is not np.ma.masked:
         editor = QLineEdit(parent)
         editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
         editor.setAlignment(Qt.AlignCenter)
         if is_number(self.dtype):
             validator = QDoubleValidator(editor)
             validator.setLocale(QLocale('C'))
             editor.setValidator(validator)
         editor.returnPressed.connect(self.commitAndCloseEditor)
         return editor
Example #26
0
    def _setup_elines_table(self):
        """The table has only functionality necessary to demonstrate how it is going
        to look. A lot more code is needed to actually make it run."""

        self._validator_peak_height = QDoubleValidator()
        self._validator_peak_height.setBottom(0.01)

        self.tbl_elines = QTableWidget()
        self.tbl_elines.setStyleSheet(
            "QTableWidget::item{color: black;}"
            "QTableWidget::item:selected{background-color: red;}"
            "QTableWidget::item:selected{color: white;}")

        self.tbl_labels = [
            "", "Z", "Line", "E, keV", "Peak Int.", "Rel. Int.(%)", "CS"
        ]
        self.tbl_cols_editable = ["Peak Int."]
        self.tbl_value_min = {"Rel. Int.(%)": 0.1}
        tbl_cols_resize_to_content = ["", "Z", "Line"]

        self.tbl_elines.setColumnCount(len(self.tbl_labels))
        self.tbl_elines.verticalHeader().hide()
        self.tbl_elines.setHorizontalHeaderLabels(self.tbl_labels)

        self.tbl_elines.setSelectionBehavior(QTableWidget.SelectRows)
        self.tbl_elines.setSelectionMode(QTableWidget.SingleSelection)
        self.tbl_elines.itemSelectionChanged.connect(
            self.tbl_elines_item_selection_changed)
        self.tbl_elines.itemChanged.connect(self.tbl_elines_item_changed)

        header = self.tbl_elines.horizontalHeader()
        for n, lbl in enumerate(self.tbl_labels):
            # Set stretching for the columns
            if lbl in tbl_cols_resize_to_content:
                header.setSectionResizeMode(n, QHeaderView.ResizeToContents)
            else:
                header.setSectionResizeMode(n, QHeaderView.Stretch)
            # Set alignment for the columns headers (HEADERS only)
            if n == 0:
                header.setDefaultAlignment(Qt.AlignCenter)
            else:
                header.setDefaultAlignment(Qt.AlignRight)

        self.cb_sel_list = []  # List of checkboxes
Example #27
0
    def __init__(self, parent=None):
        super(AxesTabWidgetView, self).__init__(parent=parent)

        self.ui = load_ui(__file__, 'axes_tab_widget.ui', baseinstance=self)
        self.setAttribute(Qt.WA_DeleteOnClose, True)

        # Set validator for the axis limit spin boxes
        for limit in ['upper', 'lower']:
            line_edit = getattr(self, f'{limit}_limit_line_edit')
            validator = QDoubleValidator()
            line_edit.setValidator(validator)
Example #28
0
    def _build_waverange_dialog(self, wave_range, line_list):

        dialog = QDialog(parent=self.centralWidget)

        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_waverange.ui"), dialog)

        dialog.min_text.setText("%.2f" % wave_range[0].value)
        dialog.max_text.setText("%.2f" % wave_range[1].value)

        validator = QDoubleValidator()
        validator.setBottom(0.0)
        validator.setDecimals(2)
        dialog.min_text.setValidator(validator)
        dialog.max_text.setValidator(validator)

        dialog.nlines_label = self._compute_nlines_in_waverange(line_list, dialog.min_text, dialog.max_text,
                                                                dialog.nlines_label)

        dialog.min_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list,
                                                 dialog.min_text, dialog.max_text, dialog.nlines_label))
        dialog.max_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list,
                                                 dialog.min_text, dialog.max_text, dialog.nlines_label))

        accepted = dialog.exec_() > 0

        amin = amax = None
        if accepted:
            return self._get_range_from_textfields(dialog.min_text, dialog.max_text)

        return (amin, amax)
Example #29
0
    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 initialize_content(self):
        # Constraints
        for widget in [
                self._content.ei_edit,
                self._content.van_mass_edit,
                self._content.sample_mass_edit,
                self._content.sample_rmm_edit,
                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,
        ]:

            dvp = QDoubleValidator(widget)
            dvp.setBottom(0.0)
            widget.setValidator(dvp)

        # Connections
        self._content.absunits_van_browse.clicked.connect(self._absunits_van_browse)
        self._content.absunits_detvan_browse.clicked.connect(self._absunits_detvan_browse)
        self._content.grouping_file_browse.clicked.connect(self._grouping_file_browse)
Example #31
0
    def __init__(self, filename, valid_style, valid_colors, used_names=None):
        """
        Widget to edit a marker properties
        :param filename: name of the ui file for this widget
        :param valid_style: list of valid line styles (eg. 'solid', 'dashed'...) used by matplotlib
        :param valid_colors: dictionary of valid colours
            keys = name of the colour
            value = corresponding matplotlib name (eg. {'red': 'C4'})
        """
        super(MarkerEditor, self).__init__()
        self.widget = load_ui(__file__, filename, baseinstance=self)
        self.widget.position.setValidator(QDoubleValidator())
        self.widget.label_x_pos.setValidator(QDoubleValidator())
        self.widget.label_y_pos.setValidator(QDoubleValidator())
        self.colors = valid_colors
        if used_names is None:
            self.used_names = []
        else:
            self.used_names = used_names

        self.widget.style.addItems(valid_style)
        self.widget.color.addItems(list(valid_colors.keys()))
Example #32
0
    def _build_GUI(self, linelist, table_view):
        panel_layout = QVBoxLayout()
        panel_layout.setSizeConstraint(QLayout.SetMaximumSize)
        self.setLayout(panel_layout)

        # GUI cannot be completely defined in a .ui file.
        # It has to be built on-the-fly here.
        self.button_pane = QWidget()
        loadUi(
            os.path.join(os.path.dirname(__file__), "ui",
                         "linelists_panel_buttons.ui"), self.button_pane)
        self.button_pane.create_set_button.clicked.connect(self._createSet)
        self.button_pane.deselect_button.clicked.connect(
            table_view.clearSelection)

        # header with line list metadata.
        info = QTextBrowser()
        info.setMaximumHeight(100)
        info.setAutoFillBackground(True)
        info.setStyleSheet("background-color: rgb(230,230,230);")
        for comment in linelist.meta['comments']:
            info.append(comment)

        # populate color picker
        model = self.button_pane.combo_box_color.model()
        for cname in ID_COLORS:
            item = QStandardItem(cname)
            item.setForeground(ID_COLORS[cname])
            item.setData(QColor(ID_COLORS[cname]), role=Qt.UserRole)
            model.appendRow(item)

        # set validators
        validator = QDoubleValidator()
        validator.setRange(0.05, 0.95, decimals=2)
        self.button_pane.height_textbox.setValidator(validator)
        validator = QDoubleValidator()
        validator.setRange(-1.e5, 1.e10, decimals=4)
        self.button_pane.redshift_textbox.setValidator(validator)

        model = self.button_pane.combo_box_z_units.model()
        for uname in ['z', 'km/s']:
            item = QStandardItem(uname)
            model.appendRow(item)

        # put it all together
        panel_layout.addWidget(info)
        panel_layout.addWidget(table_view)
        panel_layout.addWidget(self.button_pane)
Example #33
0
    def __init__(self, canvas, axes, axis_id):
        """

        :param canvas: A reference to the target canvas
        :param axes: The axes object holding the properties to be edited
        :param axis_id: A string ID for the axis
        """
        super(AxisEditor, self).__init__('axiseditor.ui', canvas)
        # suppress errors
        self.ui.errors.hide()
        # Ensure that only floats can be entered
        self.ui.editor_min.setValidator(QDoubleValidator())
        self.ui.editor_max.setValidator(QDoubleValidator())
        if figure_type(canvas.figure) == FigureType.Image:
            self.ui.logBox.hide()
            self.ui.gridBox.hide()

        self.axes = axes
        self.axis_id = axis_id
        self.lim_setter = getattr(axes, 'set_{}lim'.format(axis_id))
        self.scale_setter = getattr(axes, 'set_{}scale'.format(axis_id))
        self.linthresholdkw = 'linthres' + axis_id
        # Grid has no direct accessor from the axes
        self.axis = axes.xaxis if axis_id == 'x' else axes.yaxis
Example #34
0
    def __init__(self, value='', parent=None, get_pos=None):
        super().__init__(value, parent=parent)
        self.fm = QFontMetrics(QFont("", 0))
        self.setObjectName('slice_label')
        self.min_width = 30
        self.max_width = 200
        self.setCursor(Qt.IBeamCursor)
        self.setValidator(QDoubleValidator())
        self.textChanged.connect(self._on_text_changed)
        self._on_text_changed(value)

        self.get_pos = get_pos
        if parent is not None:
            self.min_width = 50
            self.slider = parent.slider
            self.setAlignment(Qt.AlignCenter)
Example #35
0
    def _build_GUI(self, linelist, table_view):
        panel_layout = QGridLayout()
        panel_layout.setSizeConstraint(QLayout.SetMaximumSize)
        self.setLayout(panel_layout)

        # GUI cannot be completely defined in a .ui file.
        # It has to be built on-the-fly here.
        self.button_pane = QWidget()
        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_panel_buttons.ui"), self.button_pane)

        # internal signals do not use Hub infrastructure.
        self.button_pane.create_set_button.clicked.connect(self._create_set)
        self.button_pane.deselect_button.clicked.connect(table_view.clearSelection)

        # header with line list metadata.
        info = QTextBrowser()
        info.setMaximumHeight(100)
        info.setAutoFillBackground(True)
        info.setStyleSheet("background-color: rgb(230,230,230);")
        for comment in linelist.meta['comments']:
            info.append(comment)

        # populate color picker
        model = self.button_pane.combo_box_color.model()
        for cname in ID_COLORS:
            item = QStandardItem(cname)
            item.setForeground(ID_COLORS[cname])
            item.setData(QColor(ID_COLORS[cname]), role=Qt.UserRole)
            model.appendRow(item)

        # set validators
        validator = QDoubleValidator()
        validator.setRange(0.05, 0.95, decimals=2)
        self.button_pane.height_textbox.setValidator(validator)
        validator = QDoubleValidator()
        validator.setRange(-1.e5, 1.e10, decimals=4)
        self.button_pane.redshift_textbox.setValidator(validator)

        model = self.button_pane.combo_box_z_units.model()
        for uname in ['z', 'km/s']:
            item = QStandardItem(uname)
            model.appendRow(item)

        # put it all together
        panel_layout.addWidget(info,0,0)
        panel_layout.addWidget(table_view,1,0)
        panel_layout.addWidget(self.button_pane,2,0)
    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
        """
        # 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
Example #38
0
    def _build_waverange_dialog(self, wave_range, line_list):

        dialog = QDialog()

        loadUi(os.path.join(os.path.dirname(__file__), "ui", "linelists_waverange.ui"), dialog)

        # convert from line list native units to whatever units
        # are currently being displayed in the spectral axis.
        linelist_units = wave_range[0].unit
        spectral_axis_unit = self.hub.plot_widget.spectral_axis_unit
        w0 = wave_range[0].to(spectral_axis_unit, equivalencies=u.spectral())
        w1 = wave_range[1].to(spectral_axis_unit, equivalencies=u.spectral())

        # populate labels with correct physical quantity name
        dispersion_unit = u.Unit(spectral_axis_unit or "")
        if dispersion_unit.physical_type == 'length':
            dialog.minwave_label.setText("Minimum wavelength")
            dialog.maxwave_label.setText("Maximum wavelength")
        elif dispersion_unit.physical_type == 'frequency':
            dialog.minwave_label.setText("Minimum frequency")
            dialog.maxwave_label.setText("Maximum frequency")
        elif dispersion_unit.physical_type == 'energy':
            dialog.minwave_label.setText("Minimum energy")
            dialog.maxwave_label.setText("Maximum energy")
        else:
            dialog.minwave_label.setText("Minimum disp. var.")
            dialog.maxwave_label.setText("Maximum disp. var.")

        # pick a good format to display values represented
        # in the currently selected plot units.
        if str(w0.unit) in units_formats:
            fmt = units_formats[str(w0.unit)]
        else:
            # use generic formatting for weirder units
            fmt = "%.6g"

        dialog.min_text.setText(fmt % w0.value)
        dialog.max_text.setText(fmt % w1.value)

        validator = QDoubleValidator()
        validator.setBottom(0.0)
        dialog.min_text.setValidator(validator)
        dialog.max_text.setValidator(validator)

        dialog.nlines_label = self._compute_nlines_in_waverange(line_list, dialog.min_text, dialog.max_text,
                                                                dialog.nlines_label, linelist_units, spectral_axis_unit)

        dialog.min_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list,
                                                                                          dialog.min_text,
                                                                                          dialog.max_text,
                                                                                          dialog.nlines_label,
                                                                                          linelist_units,
                                                                                          spectral_axis_unit))
        dialog.max_text.editingFinished.connect(lambda: self._compute_nlines_in_waverange(line_list,
                                                                                          dialog.min_text,
                                                                                          dialog.max_text,
                                                                                          dialog.nlines_label,
                                                                                          linelist_units,
                                                                                          spectral_axis_unit))
        accepted = dialog.exec_() > 0

        amin = amax = None
        if accepted:
            return self._get_range_from_textfields(dialog.min_text, dialog.max_text,
                                                   linelist_units, spectral_axis_unit)
        return (amin, amax)