Пример #1
0
 def init_signal(self):
     """allow clean shutdown on sigint"""
     signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2))
     # need a timer, so that QApplication doesn't block until a real
     # Qt event fires (can require mouse movement)
     # timer trick from http://stackoverflow.com/q/4938723/938949
     timer = QtCore.QTimer()
     # Let the interpreter run each 200 ms:
     timer.timeout.connect(lambda: None)
     timer.start(200)
     # hold onto ref, so the timer doesn't get cleaned up
     self._sigint_timer = timer
Пример #2
0
    def __init__(self, options, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        self.options = options
        self.port = None
        self.default_rate = 100

        self._buffer = ''
        self._serial_timer = QtCore.QTimer()
        self._serial_timer.timeout.connect(self._poll_serial)
        self._serial_timer.start(10)

        self._serial_state = self.STATE_LINE

        self._telemetry_records = {}
        self._schema_name = None
        self._config_tree_items = {}

        self._last_draw_time = 0.0

        self.ui = ui_tview_main_window.Ui_TviewMainWindow()
        self.ui.setupUi(self)

        self.ui.configTreeWidget = SizedTreeWidget()
        self.ui.configDock.setWidget(self.ui.configTreeWidget)

        self.ui.telemetryTreeWidget = SizedTreeWidget()
        self.ui.telemetryDock.setWidget(self.ui.telemetryTreeWidget)

        self.ui.telemetryTreeWidget.itemExpanded.connect(
            self._handle_tree_expanded)
        self.ui.telemetryTreeWidget.itemCollapsed.connect(
            self._handle_tree_collapsed)
        self.ui.telemetryTreeWidget.setContextMenuPolicy(
            QtCore.Qt.CustomContextMenu)
        self.ui.telemetryTreeWidget.customContextMenuRequested.connect(
            self._handle_telemetry_context_menu)

        self.ui.configTreeWidget.setItemDelegateForColumn(
            0, NoEditDelegate(self))
        self.ui.configTreeWidget.itemExpanded.connect(
            self._handle_config_expanded)
        self.ui.configTreeWidget.itemChanged.connect(
            self._handle_config_item_changed)

        self.ui.plotItemRemoveButton.clicked.connect(
            self._handle_plot_item_remove)

        self.console = TviewConsoleWidget()
        self.console.ansi_codes = False
        self.console.line_input.connect(self._handle_user_input)
        self.ui.consoleDock.setWidget(self.console)

        self.tabifyDockWidget(self.ui.configDock, self.ui.telemetryDock)

        layout = QtGui.QVBoxLayout(self.ui.plotHolderWidget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.ui.plotHolderWidget.setLayout(layout)
        self.ui.plotWidget = PlotWidget(self.ui.plotHolderWidget)
        layout.addWidget(self.ui.plotWidget)

        def update_plotwidget(value):
            self.ui.plotWidget.history_s = value

        self.ui.historySpin.valueChanged.connect(update_plotwidget)

        self._config_callback = None

        QtCore.QTimer.singleShot(0, self._handle_startup)
Пример #3
0
 def start(self):
     if self._timer is None:
         self._timer = QtCore.QTimer()
         self._timer.timeout.connect(self.poll)
     self._timer.start(self.time_to_dead * 1000)