From 788771bd751ff3df9aacf0cf29491f3054599588 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 15 Jul 2020 09:55:09 -0400 Subject: [PATCH] Change name to qtractor --- piker/ui/_exec.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/piker/ui/_exec.py b/piker/ui/_exec.py index 03d8087b..06944d0e 100644 --- a/piker/ui/_exec.py +++ b/piker/ui/_exec.py @@ -5,7 +5,6 @@ Run ``trio`` in guest mode on top of the Qt event loop. All global Qt runtime settings are mostly defined here. """ import traceback -from functools import partial import PyQt5 # noqa from pyqtgraph import QtGui @@ -21,7 +20,7 @@ from outcome import Error class MainWindow(QtGui.QMainWindow): size = (800, 500) - title = 'piker: chart' + title = 'piker chart (bby)' def __init__(self, parent=None): super().__init__(parent) @@ -29,11 +28,12 @@ class MainWindow(QtGui.QMainWindow): self.setWindowTitle(self.title) -def run_qtrio( +def run_qtractor( func, args, - main_widget, - loglevel = None, + main_widget: QtGui.QWidget, + window_type: QtGui.QMainWindow = MainWindow, + loglevel: str = None, ) -> None: # avoids annoying message when entering debugger from qt loop pyqtRemoveInputHook() @@ -42,6 +42,12 @@ def run_qtrio( if app is None: app = PyQt5.QtWidgets.QApplication([]) + # TODO: we might not need this if it's desired + # to cancel the tractor machinery on Qt loop + # close, however the details of doing that correctly + # currently seem tricky.. + app.setQuitOnLastWindowClosed(False) + # This code is from Nathaniel, and I quote: # "This is substantially faster than using a signal... for some # reason Qt signal dispatch is really slow (and relies on events @@ -74,8 +80,9 @@ def run_qtrio( app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5')) # make window and exec - window = MainWindow() + window = window_type() instance = main_widget() + instance.window = window widgets = { 'window': window, @@ -98,7 +105,7 @@ def run_qtrio( tractor._default_arbiter_port, ), # name - 'qtrio', + 'qtractor', ) # guest mode