Change name to qtractor

bar_select
Tyler Goodlet 2020-07-15 09:55:09 -04:00
parent 3aebeb5801
commit 788771bd75
1 changed files with 14 additions and 7 deletions

View File

@ -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. All global Qt runtime settings are mostly defined here.
""" """
import traceback import traceback
from functools import partial
import PyQt5 # noqa import PyQt5 # noqa
from pyqtgraph import QtGui from pyqtgraph import QtGui
@ -21,7 +20,7 @@ from outcome import Error
class MainWindow(QtGui.QMainWindow): class MainWindow(QtGui.QMainWindow):
size = (800, 500) size = (800, 500)
title = 'piker: chart' title = 'piker chart (bby)'
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
@ -29,11 +28,12 @@ class MainWindow(QtGui.QMainWindow):
self.setWindowTitle(self.title) self.setWindowTitle(self.title)
def run_qtrio( def run_qtractor(
func, func,
args, args,
main_widget, main_widget: QtGui.QWidget,
loglevel = None, window_type: QtGui.QMainWindow = MainWindow,
loglevel: str = None,
) -> None: ) -> None:
# avoids annoying message when entering debugger from qt loop # avoids annoying message when entering debugger from qt loop
pyqtRemoveInputHook() pyqtRemoveInputHook()
@ -42,6 +42,12 @@ def run_qtrio(
if app is None: if app is None:
app = PyQt5.QtWidgets.QApplication([]) 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 code is from Nathaniel, and I quote:
# "This is substantially faster than using a signal... for some # "This is substantially faster than using a signal... for some
# reason Qt signal dispatch is really slow (and relies on events # 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')) app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
# make window and exec # make window and exec
window = MainWindow() window = window_type()
instance = main_widget() instance = main_widget()
instance.window = window
widgets = { widgets = {
'window': window, 'window': window,
@ -98,7 +105,7 @@ def run_qtrio(
tractor._default_arbiter_port, tractor._default_arbiter_port,
), ),
# name # name
'qtrio', 'qtractor',
) )
# guest mode # guest mode