예제 #1
0
    def initialise_GUI(self):
        """Initialises the Tab GUI.

        This method is called automatically by BLACS.
        """

        self.connection_table_properties = (
            self.settings["connection_table"].find_by_name(
                self.device_name).properties)

        digital_outs = {}
        for pin in self.connection_table_properties["out_pins"]:
            digital_outs[f"GPIO {pin:02d}"] = {}

        # Create a single digital output
        self.create_digital_outputs(digital_outs)
        # Create widgets for output objects
        _, _, do_widgets = self.auto_create_widgets()
        # and auto place the widgets in the UI
        self.auto_place_widgets(("Flags", do_widgets))

        # Create status labels
        self.status_label = QtWidgets.QLabel("Status: Unknown")
        self.clock_status_label = QtWidgets.QLabel("Clock status: Unknown")
        self.get_tab_layout().addWidget(self.status_label)
        self.get_tab_layout().addWidget(self.clock_status_label)

        # Set the capabilities of this device
        self.supports_smart_programming(True)

        # Create status monitor timout
        self.statemachine_timeout_add(2000, self.status_monitor)
예제 #2
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QWidget()
    layout = QtWidgets.QVBoxLayout(window)
    outputbox = OutputBox(layout)

    funcs = [
        regular_print_stdout,
        regular_print_stderr,
        libc_printf,
        echo_hello,
        multiprocessing_Process,
    ]

    for f in funcs:
        button = QtWidgets.QPushButton(f.__name__)
        button.clicked.connect(f)
        layout.addWidget(button)

    redirect_stdout = OutputInterceptor('localhost', outputbox.port)
    redirect_sterr = OutputInterceptor('localhost', outputbox.port, streamname='stderr')

    redirect_stdout.connect()
    redirect_sterr.connect()

    window.resize(800, 500)
    window.show()
    app.exec_()
    redirect_stdout.disconnect()
    redirect_sterr.disconnect()
    outputbox.shutdown()
    def paintEvent(self, event):
        painter = QtWidgets.QStylePainter(self)
        option = QtWidgets.QStyleOptionTab()

        for index in range(self.count()):
            self.initStyleOption(option, index)
            tabRect = self.tabRect(index)
            tabRect.moveLeft(10)
            painter.drawControl(QtWidgets.QStyle.CE_TabBarTabShape, option)
            painter.drawText(tabRect,
                             QtCore.Qt.AlignVCenter | QtCore.Qt.TextDontClip,
                             self.tabText(index))
        painter.end()
    def __init__(self, *args, **kwargs):
        Plot.__init__(self, *args, **kwargs)
        self.points_of_interest_action = self.navigation_toolbar.addAction(
            QtGui.QIcon(':qtutils/fugue/target--plus'),
            'Add points of interest', self.on_add_points_of_interest_triggered)
        self.points_of_interest_action.setToolTip('Add points of interest')
        self.points_of_interest_action.setCheckable(True)

        self.actions_enabled = True
        self.canvas.mpl_connect('button_press_event', self.canvasClicked)

        self.remove_points_of_interest_action = self.navigation_toolbar.addAction(
            QtGui.QIcon(':qtutils/fugue/target--minus'),
            'Remove points of interest',
            self.on_remove_points_of_interest_triggered)
        self.remove_points_of_interest_action.setToolTip(
            'Remove points of interest')
        self.remove_points_of_interest_action.setCheckable(True)

        self.canvas.mpl_connect('pick_event', self.onPick)

        self.clear_points_of_interest_action = self.navigation_toolbar.addAction(
            QtGui.QIcon(':qtutils/fugue/target--exclamation'),
            'Clear all points of interest',
            self.on_clear_points_of_interest_triggered)
        self.clear_points_of_interest_action.setToolTip(
            'Cear all points of interest')

        self.done_action = self.navigation_toolbar.addAction(
            QtWidgets.QIcon(':qtutils/fugue/disk--arrow'), 'Done',
            self.save_points_of_interest)
        self.done_action.setToolTip('Save vortex locations')

        self.reject_action = self.navigation_toolbar.addAction(
            QtWidgets.QIcon(':qtutils/fugue/disk--minus'), 'Reject',
            self.on_reject)
        self.reject_action.setToolTip('Reject shot')

        self.cancel_action = self.navigation_toolbar.addAction(
            QtWidgets.QIcon(':qtutils/fugue/disk--exclamation'), 'Cancel',
            self.on_reject)
        self.cancel_action.setToolTip(
            'Cancel (do not save any results for this shot)')
    def __init__(self, imagepath):
        self.qapplication = QtWidgets.QApplication.instance()
        if self.qapplication is None:
            self.qapplication = QtWidgets.QApplication(sys.argv)
        QtWidgets.QFrame.__init__(self)
        self.icon = QtGui.QPixmap()
        self.icon.load(imagepath)
        if self.icon.isNull():
            raise ValueError("Invalid image file: {}.\n".format(imagepath))
        self.icon = self.icon.scaled(self.imwidth, self.imheight,
                                     Qt.KeepAspectRatio,
                                     Qt.SmoothTransformation)
        self.text = 'Loading'
        self.setWindowFlags(Qt.SplashScreen)
        self.setWindowOpacity(self.alpha)
        self.label = QtWidgets.QLabel(self.text)
        self.setStyleSheet("background-color: %s; font-size: 10pt" % self.BG)
        # Frame not necessary on macos, and looks ugly.
        if sys.platform != 'darwin':
            self.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.label.setWordWrap(True)
        self.label.setAlignment(Qt.AlignCenter)
        self.resize(self.w, self.h)

        image_label = QtWidgets.QLabel()
        image_label.setPixmap(self.icon)
        image_label.setAlignment(Qt.AlignCenter)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(image_label)
        layout.addWidget(self.label)

        center_point = QtWidgets.QDesktopWidget().availableGeometry().center()
        x0, y0 = center_point.x(), center_point.y()
        self.move(x0 - self.w / 2, y0 - self.h / 2)
        self._first_paint_complete = False
            except KeyError:
                # If we don't already have this figure, make a window
                # to put it in:
                self.new_figure(fig, identifier)
            else:
                if not plot.is_shown:
                    plot.show()
                    plot.update_window_size()
                plot.set_window_title(identifier, self.filepath)
                if plot.lock_axes:
                    plot.restore_axis_limits()
                plot.draw()

    def new_figure(self, fig, identifier):
        self.plots[fig] = Plot(fig, identifier, self.filepath)

    def reset_figs(self):
        pass


if __name__ == '__main__':
    filepath = from_parent.get()

    # Set a meaningful client id for zprocess.locking:
    zprocess.locking.set_client_process_name('lyse-' +
                                             os.path.basename(filepath))

    qapplication = QtWidgets.QApplication(sys.argv)
    worker = AnalysisWorker(filepath, to_parent, from_parent)
    qapplication.exec_()