diff options
Diffstat (limited to 'gr-qtgui/python/qtgui')
-rw-r--r-- | gr-qtgui/python/qtgui/CMakeLists.txt | 14 | ||||
-rwxr-xr-x | gr-qtgui/python/qtgui/range.py.cmakein (renamed from gr-qtgui/python/qtgui/range.py) | 26 | ||||
-rw-r--r-- | gr-qtgui/python/qtgui/util.py.cmakein (renamed from gr-qtgui/python/qtgui/util.py) | 3 |
3 files changed, 25 insertions, 18 deletions
diff --git a/gr-qtgui/python/qtgui/CMakeLists.txt b/gr-qtgui/python/qtgui/CMakeLists.txt index 1c20033db2..5df3a7d91b 100644 --- a/gr-qtgui/python/qtgui/CMakeLists.txt +++ b/gr-qtgui/python/qtgui/CMakeLists.txt @@ -20,12 +20,20 @@ ######################################################################## include(GrPython) +if (DESIRED_QT_VERSION MATCHES 4) + set(PY_QT_IMPORT "from PyQt4 import Qt, QtCore, QtGui as QtWidgets") +else() + set(PY_QT_IMPORT "from PyQt5 import Qt, QtCore, QtWidgets") +endif() + +configure_file(range.py.cmakein "${CMAKE_CURRENT_BINARY_DIR}/range.py" @ONLY) +configure_file(util.py.cmakein "${CMAKE_CURRENT_BINARY_DIR}/util.py" @ONLY) + GR_PYTHON_INSTALL( FILES __init__.py - range.py - util.py + "${CMAKE_CURRENT_BINARY_DIR}/range.py" + "${CMAKE_CURRENT_BINARY_DIR}/util.py" DESTINATION ${GR_PYTHON_DIR}/gnuradio/qtgui - COMPONENT "qtgui_python" ) ######################################################################## diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py.cmakein index ca42bf71f7..00db509762 100755 --- a/gr-qtgui/python/qtgui/range.py +++ b/gr-qtgui/python/qtgui/range.py.cmakein @@ -21,7 +21,7 @@ # Boston, MA 02110-1301, USA. # -from PyQt4 import Qt, QtCore, QtGui +@PY_QT_IMPORT@ import util class Range(object): @@ -64,10 +64,10 @@ class Range(object): return (val*self.step+self.min) -class RangeWidget(QtGui.QWidget): +class RangeWidget(QtWidgets.QWidget): def __init__(self, ranges, slot, label, style, rangeType=float): """ Creates the QT Range widget """ - QtGui.QWidget.__init__(self) + QtWidgets.QWidget.__init__(self) self.range = ranges self.style = style @@ -98,10 +98,10 @@ class RangeWidget(QtGui.QWidget): layout.addWidget(self.d_widget) self.setLayout(layout) - class Dial(QtGui.QDial): + class Dial(QtWidgets.QDial): """ Creates the range using a dial """ def __init__(self, parent, ranges, slot, rangeType=float): - QtGui.QDial.__init__(self, parent) + QtWidgets.QDial.__init__(self, parent) self.rangeType = rangeType @@ -124,10 +124,10 @@ class RangeWidget(QtGui.QWidget): val = self.range.map_range(value) self.notifyChanged(self.rangeType(val)) - class Slider(QtGui.QSlider): + class Slider(QtWidgets.QSlider): """ Creates the range using a slider """ def __init__(self, parent, ranges, slot, rangeType=float): - QtGui.QSlider.__init__(self, QtCore.Qt.Horizontal, parent) + QtWidgets.QSlider.__init__(self, QtCore.Qt.Horizontal, parent) self.rangeType = rangeType @@ -166,18 +166,18 @@ class RangeWidget(QtGui.QWidget): event.accept() # Use repaint rather than calling the super mousePressEvent. # Calling super causes issue where slider jumps to wrong value. - QtGui.QSlider.repaint(self) + QtWidgets.QSlider.repaint(self) def mouseMoveEvent(self, event): new = self.minimum() + ((self.maximum()-self.minimum()) * event.x()) / self.width() self.setValue(new) event.accept() - QtGui.QSlider.repaint(self) + QtWidgets.QSlider.repaint(self) - class Counter(QtGui.QDoubleSpinBox): + class Counter(QtWidgets.QDoubleSpinBox): """ Creates the range using a counter """ def __init__(self, parent, ranges, slot, rangeType=float): - QtGui.QDoubleSpinBox.__init__(self, parent) + QtWidgets.QDoubleSpinBox.__init__(self, parent) self.rangeType = rangeType @@ -196,10 +196,10 @@ class RangeWidget(QtGui.QWidget): """ Handle the valueChanged signal by converting to the right type """ self.notifyChanged(self.rangeType(value)) - class CounterSlider(QtGui.QWidget): + class CounterSlider(QtWidgets.QWidget): """ Creates the range using a counter and slider """ def __init__(self, parent, ranges, slot, rangeType=float): - QtGui.QWidget.__init__(self, parent) + QtWidgets.QWidget.__init__(self, parent) self.rangeType = rangeType diff --git a/gr-qtgui/python/qtgui/util.py b/gr-qtgui/python/qtgui/util.py.cmakein index d2e9495ac6..ca2b3b37c5 100644 --- a/gr-qtgui/python/qtgui/util.py +++ b/gr-qtgui/python/qtgui/util.py.cmakein @@ -21,7 +21,7 @@ # Boston, MA 02110-1301, USA. # -from PyQt4 import Qt, QtCore, QtGui +@PY_QT_IMPORT@ from gnuradio import gr def check_set_qss(): @@ -32,4 +32,3 @@ def check_set_qss(): app.setStyleSheet(open(qssfile).read()) except: print "WARNING: bad QSS file, %s"%(qssfile) - |