Kill the tractor tree on window close.
This makes it so you don't have to ctrl-c kill apps. Add in the experimental openGL support even though I'm pretty sure it's not being used much for curve plotting (but could be wrong).vwap_backup
parent
c183a428ef
commit
a5f622506d
|
@ -26,6 +26,7 @@ from typing import Tuple, Callable, Dict, Any
|
||||||
|
|
||||||
# Qt specific
|
# Qt specific
|
||||||
import PyQt5 # noqa
|
import PyQt5 # noqa
|
||||||
|
import pyqtgraph as pg
|
||||||
from pyqtgraph import QtGui
|
from pyqtgraph import QtGui
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
@ -37,6 +38,12 @@ import tractor
|
||||||
from outcome import Error
|
from outcome import Error
|
||||||
|
|
||||||
|
|
||||||
|
# pyqtgraph global config
|
||||||
|
# might as well enable this for now?
|
||||||
|
pg.useOpenGL = True
|
||||||
|
pg.enableExperimental = True
|
||||||
|
|
||||||
|
|
||||||
# singleton app per actor
|
# singleton app per actor
|
||||||
_qt_app: QtGui.QApplication = None
|
_qt_app: QtGui.QApplication = None
|
||||||
_qt_win: QtGui.QMainWindow = None
|
_qt_win: QtGui.QMainWindow = None
|
||||||
|
@ -67,6 +74,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||||
self.setMinimumSize(*self.size)
|
self.setMinimumSize(*self.size)
|
||||||
self.setWindowTitle(self.title)
|
self.setWindowTitle(self.title)
|
||||||
|
|
||||||
|
def closeEvent(self, event: 'QCloseEvent') -> None:
|
||||||
|
"""Cancel the root actor asap.
|
||||||
|
|
||||||
|
"""
|
||||||
|
tractor.current_actor().cancel_soon()
|
||||||
|
|
||||||
|
|
||||||
def run_qtractor(
|
def run_qtractor(
|
||||||
func: Callable,
|
func: Callable,
|
||||||
|
@ -131,6 +144,9 @@ def run_qtractor(
|
||||||
instance = main_widget()
|
instance = main_widget()
|
||||||
instance.window = window
|
instance.window = window
|
||||||
|
|
||||||
|
# kill the app when root actor terminates
|
||||||
|
tractor._actor._lifetime_stack.callback(app.quit)
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
'window': window,
|
'window': window,
|
||||||
'main': instance,
|
'main': instance,
|
||||||
|
|
Loading…
Reference in New Issue