diff options
Diffstat (limited to 'gr-qtgui/python/qtgui')
-rw-r--r-- | gr-qtgui/python/qtgui/CMakeLists.txt | 10 | ||||
-rwxr-xr-x | gr-qtgui/python/qtgui/range.py.cmakein (renamed from gr-qtgui/python/qtgui/range.py) | 27 |
2 files changed, 22 insertions, 15 deletions
diff --git a/gr-qtgui/python/qtgui/CMakeLists.txt b/gr-qtgui/python/qtgui/CMakeLists.txt index 212c98ebb4..23e75e6583 100644 --- a/gr-qtgui/python/qtgui/CMakeLists.txt +++ b/gr-qtgui/python/qtgui/CMakeLists.txt @@ -20,9 +20,17 @@ ######################################################################## 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) + GR_PYTHON_INSTALL( FILES __init__.py - range.py + "${CMAKE_CURRENT_BINARY_DIR}/range.py" DESTINATION ${GR_PYTHON_DIR}/gnuradio/qtgui ) diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py.cmakein index 3eafc9002e..45aa762ae3 100755 --- a/gr-qtgui/python/qtgui/range.py +++ b/gr-qtgui/python/qtgui/range.py.cmakein @@ -21,8 +21,7 @@ # Boston, MA 02110-1301, USA. # -from PyQt4 import Qt, QtCore, QtGui - +@PY_QT_IMPORT@ class Range(object): def __init__(self, minv, maxv, step, default, min_length): @@ -63,10 +62,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 @@ -97,10 +96,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 @@ -123,10 +122,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 @@ -165,18 +164,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 @@ -195,10 +194,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 |