Commit 77a5acec authored by Jameson Graef Rollins's avatar Jameson Graef Rollins
Browse files

qtpy option

Would prefer to use PySide2 or PyQt5 directly, but those are not available
on older systems.  qtpy provides a shim for all possible Qt APIs.  But
unfortunately even qtpy is not on SL7, so we fall back to pyqt4.

Only minor conversion issues.
parent 83828b66
......@@ -7,7 +7,10 @@ except ImportError:
pass
import argparse
from gpstime import gpstime, GPSTimeException
from PyQt4.QtGui import QApplication, QStyleFactory
try:
from qtpy.QtWidgets import QApplication, QStyleFactory
except ImportError:
from PyQt4.QtGui import QApplication, QStyleFactory
import signal
try:
from setproctitle import setproctitle
......
......@@ -2,7 +2,10 @@
from __future__ import division
#import pyqtgraph as pg
from . import pghacks as pg
from PyQt4.QtCore import Qt
try:
from qtpy.QtCore import Qt
except ImportError:
from PyQt4.QtCore import Qt
import numpy as np
......@@ -10,8 +13,11 @@ LABEL_FILL = (0, 0, 0, 200)
class Crosshair:
__slots__ = ['scope', 'hline', 'label',
'plots', 'active_plot', 'last_pos']
__slots__ = [
'__weakref__',
'scope', 'hline', 'label',
'plots', 'active_plot', 'last_pos',
]
pen = pg.mkPen(style=Qt.DotLine)
......@@ -105,7 +111,10 @@ class Crosshair:
class TCursors:
__slots__ = ['plots']
__slots__ = [
'__weakref__',
'plots',
]
def __init__(self):
self.plots = []
......@@ -183,7 +192,10 @@ class TCursors:
class YCursors:
__slots__ = ['Y1', 'Y2', 'diff', 'plot']
__slots__ = [
'__weakref__',
'Y1', 'Y2', 'diff', 'plot',
]
def __init__(self):
pen = pg.mkPen(style=Qt.DashLine)
......
import numpy as np
import collections
from gpstime import gpsnow
from PyQt4.QtCore import QObject, pyqtSignal, pyqtSlot
try:
from qtpy import QtCore
from qtpy.QtCore import Signal, Slot
except ImportError:
from PyQt4 import QtCore
from PyQt4.QtCore import pyqtSignal as Signal
from PyQt4.QtCore import pyqtSlot as Slot
import traceback
import logging
......@@ -19,6 +25,7 @@ class DataBuffer(object):
"""
__slots__ = [
'__weakref__',
'channel', 'ctype', 'sample_rate',
'data', 'size', 'gps_start',
'lookback', 'lookback_samples_max',
......@@ -143,7 +150,10 @@ class DataBufferDict(object):
DataBuffer.
"""
__slots__ = ['buffers', 'gps_start', 'gps_end', 'lookback']
__slots__ = [
'__weakref__',
'buffers', 'gps_start', 'gps_end', 'lookback',
]
def __init__(self, nds_buffers, lookback):
self.buffers = {}
......@@ -205,15 +215,15 @@ class DataBufferDict(object):
self.buffers[chan].extend(buf)
class DataStore(QObject):
data_retrieve_start = pyqtSignal(str)
new_data = pyqtSignal('PyQt_PyObject')
data_retrieve_done = pyqtSignal(str)
class DataStore(QtCore.QObject):
data_retrieve_start = Signal(str)
new_data = Signal('PyQt_PyObject')
data_retrieve_done = Signal(str)
TREND_TYPES = ['raw', 'sec', 'min']
def __init__(self, lookback=5):
super(QObject, self).__init__()
super(QtCore.QObject, self).__init__()
self.init = True
# use a counter to hold references to the channels, so that
# channels as many channel referneces as needed can be added,
......@@ -383,7 +393,7 @@ class DataStore(QObject):
t.start()
self.threads[tid] = t
@pyqtSlot('PyQt_PyObject')
@Slot('PyQt_PyObject')
def remote_recv(self, recv):
trend = recv[0]
cmd = recv[1]
......@@ -422,7 +432,7 @@ class DataStore(QObject):
self.db[trend].extend(dbd)
self._emit_data(trend, online=cmd=='online')
@pyqtSlot('PyQt_PyObject')
@Slot('PyQt_PyObject')
def remote_done(self, recv):
tid, error = recv
logging.debug("DATA DONE: {} {}".format(tid, error))
......
......@@ -2,7 +2,12 @@ from __future__ import division
import time
import numpy as np
from contextlib import closing
from PyQt4.QtCore import QThread, QMutex, pyqtSignal
try:
from qtpy import QtCore
from qtpy.QtCore import Signal
except ImportError:
from PyQt4 import QtCore
from PyQt4.QtCore import pyqtSignal as Signal
import logging
import nds2
......@@ -200,9 +205,9 @@ def parse_channel(channel):
##################################################
class NDSThread(QThread):
new_data = pyqtSignal('PyQt_PyObject')
done = pyqtSignal('PyQt_PyObject')
class NDSThread(QtCore.QThread):
new_data = Signal('PyQt_PyObject')
done = Signal('PyQt_PyObject')
_type_map = {'raw': None, 'sec': 's', 'min': 'm'}
......@@ -234,7 +239,7 @@ class NDSThread(QThread):
self.start_end = (start, end)
else:
self.start_end = None
self._run_lock = QMutex()
self._run_lock = QtCore.QMutex()
self._running = True
def emit_data(self, bufs):
......
......@@ -5,8 +5,11 @@ import weakref
import numpy as np
import pyqtgraph as pg
from pyqtgraph import PlotItem, PlotDataItem, FillBetweenItem
from PyQt4 import QtCore, QtGui
import PyQt4.QtGui as QtWidgets
try:
from qtpy import QtCore, QtGui, QtWidgets
except ImportError:
from PyQt4 import QtCore, QtGui
import PyQt4.QtGui as QtWidgets
import logging
from . import layout
......
......@@ -3,15 +3,17 @@ from __future__ import division
import os
import numpy as np
import pyqtgraph as pg
from PyQt4 import QtGui
from PyQt4.QtGui import QStyle
try:
from qtpy import QtGui
from qtpy.QtWidgets import QStyle
from qtpy import uic
except ImportError:
from PyQt4 import QtGui
from PyQt4.QtGui import QStyle
from PyQt4 import uic
from gpstime import gpstime, GPSTimeException
import logging
from PyQt4 import uic
Ui_MainWindow, QMainWindow = uic.loadUiType(
os.path.join(os.path.dirname(__file__), 'scope.ui'))
from . import __version__
from . import const
from .data import DataStore
......@@ -64,7 +66,11 @@ def _preferred_trend_for_span(span):
##################################################
class NDScope(QtGui.QMainWindow, Ui_MainWindow):
Ui_MainWindow, QMainWindow = uic.loadUiType(
os.path.join(os.path.dirname(__file__), 'scope.ui'))
class NDScope(QMainWindow, Ui_MainWindow):
def __init__(self, layout):
"""initilize NDScope object
......
......@@ -7,7 +7,10 @@ LABEL_FILL = (0, 0, 0, 200)
class Trigger:
__slots__ = ['channel', 'line', 'invert', 'single']
__slots__ = [
'__weakref__',
'channel', 'line', 'invert', 'single',
]
def __init__(self):
self.channel = None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment