Beispiel #1
0
    def __init__(self, global_min, global_max, global_step, unit, ndecimals):
        LayoutWidget.__init__(self)

        def apply_properties(spinbox):
            spinbox.setDecimals(ndecimals)
            if global_min is not None:
                spinbox.setMinimum(global_min)
            else:
                spinbox.setMinimum(float("-inf"))
            if global_max is not None:
                spinbox.setMaximum(global_max)
            else:
                spinbox.setMaximum(float("inf"))
            if global_step is not None:
                spinbox.setSingleStep(global_step)
            if unit:
                spinbox.setSuffix(" " + unit)

        self.addWidget(QtGui.QLabel("Min:"), 0, 0)
        self.min = QtGui.QDoubleSpinBox()
        apply_properties(self.min)
        self.addWidget(self.min, 0, 1)

        self.addWidget(QtGui.QLabel("Max:"), 0, 2)
        self.max = QtGui.QDoubleSpinBox()
        apply_properties(self.max)
        self.addWidget(self.max, 0, 3)

        self.addWidget(QtGui.QLabel("#Points:"), 0, 4)
        self.npoints = QtGui.QSpinBox()
        self.npoints.setMinimum(2)
        self.npoints.setValue(10)
        self.addWidget(self.npoints, 0, 5)
Beispiel #2
0
    def __init__(self, procdesc):
        LayoutWidget.__init__(self)

        self.stack = QtGui.QStackedWidget()
        self.addWidget(self.stack, 1, 0, colspan=4)

        self.scale = procdesc["scale"]

        gmin, gmax = procdesc["global_min"], procdesc["global_max"]
        gstep = procdesc["global_step"]
        unit = procdesc["unit"]
        ndecimals = procdesc["ndecimals"]

        self.v_noscan = QtGui.QDoubleSpinBox()
        self.v_noscan.setDecimals(ndecimals)
        if gmin is not None:
            self.v_noscan.setMinimum(gmin / self.scale)
        else:
            self.v_noscan.setMinimum(float("-inf"))
        if gmax is not None:
            self.v_noscan.setMaximum(gmax / self.scale)
        else:
            self.v_noscan.setMaximum(float("inf"))
        self.v_noscan.setSingleStep(gstep / self.scale)
        if unit:
            self.v_noscan.setSuffix(" " + unit)
        self.v_noscan_gr = LayoutWidget()
        self.v_noscan_gr.addWidget(QtGui.QLabel("Value:"), 0, 0)
        self.v_noscan_gr.addWidget(self.v_noscan, 0, 1)
        self.stack.addWidget(self.v_noscan_gr)

        self.v_linear = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals)
        self.stack.addWidget(self.v_linear)

        self.v_random = _Range(gmin, gmax, gstep, unit, self.scale, ndecimals)
        self.stack.addWidget(self.v_random)

        self.v_explicit = QtGui.QLineEdit()
        self.v_explicit_gr = LayoutWidget()
        self.v_explicit_gr.addWidget(QtGui.QLabel("Sequence:"), 0, 0)
        self.v_explicit_gr.addWidget(self.v_explicit, 0, 1)
        self.stack.addWidget(self.v_explicit_gr)

        self.noscan = QtGui.QRadioButton("No scan")
        self.linear = QtGui.QRadioButton("Linear")
        self.random = QtGui.QRadioButton("Random")
        self.explicit = QtGui.QRadioButton("Explicit")
        radiobuttons = QtGui.QButtonGroup()
        for n, b in enumerate(
            [self.noscan, self.linear, self.random, self.explicit]):
            self.addWidget(b, 0, n)
            radiobuttons.addButton(b)
            b.toggled.connect(self.select_page)

        if "default" in procdesc:
            self.set_argument_value(procdesc["default"])
        else:
            self.noscan.setChecked(True)