Beispiel #1
0
 def __init__(self, instruments, *args, names=(), **kwargs):
     super().__init__(*args, **kwargs)
     self.tab = QtGui.QTabWidget()
     if not names:
         names = [type(instrument).__name__ for instrument in instruments]
     for name, instrument in zip(names, instruments):
         self.add_tab(name, instrument)
     layout = QtGui.QGridLayout()
     layout.addWidget(self.tab, 0, 0)
     self.setLayout(layout)
     self.setWindowTitle("Instrument Control")
Beispiel #2
0
    def _layout(self):
        parameters = self._procedure.parameter_objects()
        vbox = QtGui.QVBoxLayout(self)
        vbox.setSpacing(6)

        directory = getattr(self, self._inputs["directory_inputs"])
        font = QtGui.QFont()
        font.setBold(True)
        directory.label.setFont(font)
        vbox.addWidget(directory)
        grid = QtGui.QGridLayout()
        for index, (_,
                    parameter) in enumerate(self._inputs["frequency_inputs"]):
            label = QtGui.QLabel()
            label.setText(parameters[parameter].name)
            grid.addWidget(label, 0, index)
            text_edit = QtGui.QTextEdit()
            text_edit.sizeHint = lambda: QtCore.QSize(0, 120)
            grid.addWidget(getattr(self, parameter), 1, index)
        vbox.addLayout(grid)

        for inputs in self._inputs["sweep_inputs"]:
            label = QtGui.QLabel()
            label.setText(inputs[-1] + ":")
            font = QtGui.QFont()
            font.setBold(True)
            label.setFont(font)
            vbox.addWidget(label)
            hbox = QtGui.QHBoxLayout()
            for name in inputs[1:-1]:
                if not isinstance(getattr(self, name), self.NO_LABEL_INPUTS):
                    label = QtGui.QLabel(self, width=1)
                    label.setText("%s:" % parameters[name].name)
                    hbox.addWidget(label)
                input_box = getattr(self, name)
                hbox.addWidget(input_box)
                hbox.addStretch()
            vbox.addLayout(hbox)

            self.setLayout(vbox)

        directory_inputs = [self._inputs["directory_inputs"]]
        frequency_inputs = [
            inputs[1] for inputs in self._inputs["frequency_inputs"]
        ]
        sweep_inputs = [
            item for inputs in self._inputs["sweep_inputs"]
            for item in inputs[1:-1]
        ]

        self._inputs = directory_inputs + frequency_inputs + sweep_inputs