Ejemplo n.º 1
0
    def _setup_ui(self):
        preview_tab = QtGui.QTabWidget()
        param_vbox = QtGui.QVBoxLayout()
        param_vbox_widget = QtGui.QWidget()

        self.plot_widget = []
        self.plot = []
        vbox_widget = []
        vbox = []
        for index, plot_widget in enumerate(self.plot_widget_classes):
            vbox_widget.append(QtGui.QWidget())
            vbox.append(QtGui.QVBoxLayout())
            color_cycle = self.color_cycle[:1]
            self.plot_widget.append(
                plot_widget(self.columns,
                            x_axes=self.x_axes[index],
                            y_axes=self.y_axes[index],
                            x_label=self.x_labels[index],
                            y_label=self.y_labels[index],
                            legend_text=self.legend_text[index],
                            color_cycle=color_cycle))
            self.plot.append(self.plot_widget[-1].plot)
            vbox[-1].addWidget(self.plot_widget[-1])
            vbox_widget[-1].setLayout(vbox[-1])
            preview_tab.addTab(vbox_widget[-1], self.plot_names[index])

        self.preview_param = QtGui.QTreeWidget()
        param_header = QtGui.QTreeWidgetItem(["Name", "Value"])
        self.preview_param.setHeaderItem(param_header)
        self.preview_param.setColumnWidth(0, 150)
        self.preview_param.setAlternatingRowColors(True)

        param_vbox.addWidget(self.preview_param)
        param_vbox_widget.setLayout(param_vbox)
        preview_tab.addTab(param_vbox_widget, "Run Parameters")
        self.layout().addWidget(preview_tab, 0, 3, 4, 1)
        self.layout().setColumnStretch(3, 2)
        self.setMinimumSize(900, 500)
        self.resize(1300, 500)

        self.setFileMode(QtGui.QFileDialog.ExistingFiles)
        self.currentChanged.connect(self.update_plot)
Ejemplo n.º 2
0
    def _layout(self):
        self.main = QtGui.QWidget(self)

        inputs_dock = QtGui.QWidget(self)
        inputs_vbox = QtGui.QVBoxLayout(self.main)

        hbox = QtGui.QHBoxLayout()
        hbox.setSpacing(10)
        hbox.setContentsMargins(-1, 6, -1, 6)
        hbox.addWidget(self.queue_button)
        hbox.addWidget(self.abort_button)
        hbox.addWidget(self.stop_button)
        hbox.addStretch()

        inputs_vbox.addWidget(self.inputs)
        inputs_vbox.addLayout(hbox)
        inputs_vbox.addStretch()
        inputs_dock.setLayout(inputs_vbox)

        dock = QtGui.QDockWidget('Input Parameters')
        dock.setWidget(inputs_dock)
        dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock)

        tabs = QtGui.QTabWidget(self.main)
        tabs.addTab(self.plot_widget, "Results Graph")
        tabs.addTab(self.log_widget, "Experiment Log")

        splitter = QtGui.QSplitter(QtCore.Qt.Vertical)
        splitter.addWidget(tabs)
        splitter.addWidget(self.browser_widget)
        self.plot_widget.setMinimumSize(100, 200)

        vbox = QtGui.QVBoxLayout(self.main)
        vbox.setSpacing(0)
        vbox.addWidget(splitter)

        self.main.setLayout(vbox)
        self.setCentralWidget(self.main)
        self.main.show()
        self.resize(1000, 800)
Ejemplo n.º 3
0
    def _layout(self):
        # make the sweep dock widget
        base_dock = QtGui.QWidget(self)
        base_inputs_vbox = QtGui.QVBoxLayout()
        base_inputs_vbox.addWidget(self.base_inputs_widget)
        base_inputs_vbox.addStretch(0)
        base_dock.setLayout(base_inputs_vbox)
        # add the dock widget to the left
        base_inputs_dock = QtGui.QDockWidget('Sweeps')
        base_inputs_dock.setWidget(base_dock)
        features = base_inputs_dock.features()
        base_inputs_dock.setFeatures(features
                                     & ~QtGui.QDockWidget.DockWidgetClosable)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, base_inputs_dock)

        super()._layout()
Ejemplo n.º 4
0
    def add_tab(self, name, instrument):
        vbox = QtGui.QVBoxLayout()
        for label, method, arguments in instrument.CONTROL:
            hbox = QtGui.QHBoxLayout()
            label_widget = QtGui.QLabel(label + ":")
            hbox.addWidget(label_widget)
            hbox.addStretch()
            inputs = []
            for argument in arguments:
                if argument[0] is not float:
                    raise ValueError(
                        "Non-float arguments are not implemented yet.")
                inputs.append(QtGui.QDoubleSpinBox())
                if len(argument) > 1 and argument[1]:
                    inputs[-1].setPrefix(argument[1])
                if len(argument) > 2 and argument[2]:
                    inputs[-1].setSuffix(argument[2])
                if len(argument) > 3 and (argument[3] or argument[3] == 0):
                    inputs[-1].setDecimals(argument[3])
                if len(argument) > 4 and (argument[4] or argument[4] == 0):
                    inputs[-1].setMaximum(argument[4])
                if len(argument) > 5 and (argument[5] or argument[5] == 0):
                    inputs[-1].setMinimum(argument[5])
                hbox.addWidget(inputs[-1])

            def evaluate(inst, func, values):
                def run():
                    try:
                        getattr(inst, func)(*[v.value() for v in values])
                    except Exception as error:
                        logging.exception(error)
                        raise error

                thread = threading.Thread(target=run)
                thread.start()

            write = QtGui.QPushButton()
            write.setText("Send Command")
            write.clicked.connect(partial(evaluate, instrument, method,
                                          inputs))
            hbox.addWidget(write)
            vbox.addLayout(hbox)
        vbox.addStretch()
        tab_widget = QtGui.QWidget()
        tab_widget.setLayout(vbox)
        self.tab.addTab(tab_widget, name)
Ejemplo n.º 5
0
    def _layout(self):
        # main window widget
        self.main = QtGui.QWidget(self)

        # make the parameters dock widget
        inputs_dock = QtGui.QWidget(self)
        inputs_vbox = QtGui.QVBoxLayout()
        inputs_vbox.addWidget(self.inputs)
        hbox = QtGui.QHBoxLayout()
        hbox.setContentsMargins(-1, 6, -1, 6)
        hbox.addStretch()
        hbox.addWidget(self.queue_button)
        hbox.addStretch()
        hbox.addWidget(self.abort_button)
        hbox.addStretch()
        hbox.addWidget(self.abort_all_button)
        hbox.addStretch()
        inputs_vbox.addLayout(hbox)
        inputs_vbox.addStretch()
        inputs_dock.setLayout(inputs_vbox)
        # add the dock to the right
        dock = QtGui.QDockWidget('Parameters')
        dock.setWidget(inputs_dock)
        features = dock.features()
        dock.setFeatures(features & ~QtGui.QDockWidget.DockWidgetClosable)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock)

        # make indicators dock widget on the left
        if self.indicators.inputs or self.persistent_indicators:
            indicator_dock = QtGui.QWidget(self)
            indicator_vbox = QtGui.QVBoxLayout()
            if self.indicators.inputs:
                indicator_vbox.addWidget(self.indicators)
            for indicator in self.persistent_indicators:
                indicator_vbox.addWidget(indicator)
            indicator_vbox.addStretch()
            indicator_dock.setLayout(indicator_vbox)
            indicator_dock_widget = QtGui.QDockWidget('Indicators')
            indicator_dock_widget.setWidget(indicator_dock)
            features = indicator_dock_widget.features()
            indicator_dock_widget.setFeatures(
                features & ~QtGui.QDockWidget.DockWidgetClosable)
            self.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
                               indicator_dock_widget)

        # make the browser dock widget
        browser_dock = QtGui.QWidget(self)
        browser_vbox = QtGui.QVBoxLayout()
        browser_vbox.addWidget(self.browser_widget)
        browser_dock.setLayout(browser_vbox)
        # add the dock to the bottom
        browser_dock_widget = QtGui.QDockWidget('Browser')
        browser_dock_widget.setWidget(browser_dock)
        features = browser_dock_widget.features()
        browser_dock_widget.setFeatures(
            features & ~QtGui.QDockWidget.DockWidgetClosable)
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, browser_dock_widget)

        # make the plot tabs
        tabs = QtGui.QTabWidget(self.main)
        for index, plot_widget in enumerate(self.plot_widget):
            tabs.addTab(plot_widget, self.plot_names[index])
        tabs.addTab(self.log_widget, "Log")
        self.plot_widget[0].setMinimumSize(100, 200)
        # add the tabs as the main window layout
        vbox = QtGui.QVBoxLayout(self.main)
        vbox.setSpacing(0)
        vbox.addWidget(tabs)
        self.main.setLayout(vbox)

        # set the central widget and show
        self.setCentralWidget(self.main)
        self.main.show()
        self.resize(1400, 1000)