[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/05: qtgui: Replaced pyqwt range block wi
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/05: qtgui: Replaced pyqwt range block with working pyqt version. |
Date: |
Thu, 2 Apr 2015 22:18:19 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 14eb3cc5bf6ba94c120f5dceb3c715fe7f0a099c
Author: Seth Hitefield <address@hidden>
Date: Wed Apr 1 15:03:30 2015 -0700
qtgui: Replaced pyqwt range block with working pyqt version.
---
gr-qtgui/grc/qtgui_range.xml | 21 +++---
gr-qtgui/python/qtgui/__init__.py | 2 +-
gr-qtgui/python/qtgui/range.py | 152 +++++++++++++++++++++-----------------
3 files changed, 98 insertions(+), 77 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml
index ecbd28a..7ceab5b 100644
--- a/gr-qtgui/grc/qtgui_range.xml
+++ b/gr-qtgui/grc/qtgui_range.xml
@@ -8,12 +8,16 @@
<block>
<name>QT GUI Range</name>
<key>variable_qtgui_range</key>
- <import>from gnuradio.qtgui import Range</import>
+ <import>from gnuradio.qtgui import Range, RangeWidget</import>
<var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $win = 'self._%s'%$id
-$(win) = Range($start, $stop, $step, $value, "$widget")
-$(gui_hint()($win))
- </make>
+ <make>#set $win = 'self._%s_win'%$id
+#if not $label()
+ #set $label = '"%s"'%$id
+#end if
+range = Range($start, $stop, $step, $value)
+$(win) = RangeWidget(range, self.set_$(id), $label, "$widget")
+$(gui_hint()($win))</make>
+ <callback>self.set_$(id)($value)</callback>
<param>
<name>Label</name>
<key>label</key>
@@ -54,15 +58,14 @@ $(gui_hint()($win))
<option><name>Counter +
Slider</name><key>counter_slider</key></option>
<option><name>Counter</name><key>counter</key></option>
<option><name>Slider</name><key>slider</key></option>
- <option><name>Knob</name><key>knob</key></option>
- <option><name>Thermo</name><key>thermo</key></option>
+ <option><name>Knob</name><key>dial</key></option>
</param>
<param>
<name>Orientation</name>
<key>orient</key>
<value>Qt.Horizontal</value>
<type>enum</type>
- <hide>#if $widget() in ("slider", "thermo") then 'part' else
'all'#</hide>
+ <hide>#if $widget() == "slider" then 'part' else 'all'#</hide>
<option>
<name>Horizontal</name>
<key>Qt.Horizontal</key>
@@ -81,7 +84,7 @@ $(gui_hint()($win))
<key>min_len</key>
<value>200</value>
<type>int</type>
- <hide>#if $widget().split('_')[0] in ("slider", "counter",
"thermo") then 'part' else 'all'#</hide>
+ <hide>#if $widget().split('_')[0] in ("slider", "counter") then
'part' else 'all'#</hide>
</param>
<param>
<name>GUI Hint</name>
diff --git a/gr-qtgui/python/qtgui/__init__.py
b/gr-qtgui/python/qtgui/__init__.py
index d74d0f2..224bde0 100644
--- a/gr-qtgui/python/qtgui/__init__.py
+++ b/gr-qtgui/python/qtgui/__init__.py
@@ -34,4 +34,4 @@ except ImportError:
__path__.append(os.path.join(dirname, "..", "..", "swig"))
from qtgui_swig import *
-from range import Range
+from range import Range, RangeWidget
diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py
index 1d19818..7a647bd 100755
--- a/gr-qtgui/python/qtgui/range.py
+++ b/gr-qtgui/python/qtgui/range.py
@@ -23,83 +23,101 @@
from PyQt4 import Qt, QtCore, QtGui
-
-class Range(QtGui.QWidget):
-
- def __init__(self, min, max, step, default, style):
- QtGui.QWidget.__init__(self)
-
+class Range(object):
+ def __init__(self, min, max, step, default):
self.min = min
self.max = max
self.step = step
self.default = default
- if style == "dial":
- self.setupDial()
- elif style == "slider":
- self.setupSlider()
- elif style == "counter":
- self.setupCounter()
- elif style == "counter_slider":
- self.setupCounterSlider()
-
+class RangeWidget(QtGui.QWidget):
+ def __init__(self, range, slot, label, style):
+ """ Creates the QT Range widget """
+ QtGui.QWidget.__init__(self)
- def setupCounterSlider(self):
- """ Creates the range using a counter and slider """
+ self.range = range
layout = Qt.QHBoxLayout()
- slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
- slider.setFocusPolicy(QtCore.Qt.NoFocus)
- slider.setRange(self.min, self.max)
- slider.setPageStep(self.step)
- slider.setSingleStep(self.step)
- slider.setTracking(False)
- slider.setInvertedControls(True)
- layout.addWidget(slider)
-
- counter = QtGui.QDoubleSpinBox(self)
- counter.setRange(self.min, self.max)
- counter.setSingleStep(self.step)
- counter.setDecimals(0)
- layout.addWidget(counter)
-
- # Wire the events to each other
- counter.valueChanged.connect(slider.setValue)
- slider.valueChanged.connect(counter.setValue)
+ label = Qt.QLabel(label)
+ layout.addWidget(label)
- self.setLayout(layout)
-
- def setupCounter(self):
- """ Creates the range using a counter """
+ if style == "dial":
+ layout.addWidget(self.Dial(self, range, slot))
+ elif style == "slider":
+ layout.addWidget(self.Slider(self, range, slot))
+ elif style == "counter":
+ layout.addWidget(self.Counter(self, range, slot))
+ elif style == "counter_slider":
+ layout.addWidget(self.CounterSlider(self, range, slot))
+ else:
+ layout.addWidget(self.CounterSlider(self, range, slot))
- layout = Qt.QHBoxLayout()
- counter = QtGui.QDoubleSpinBox(self)
- counter.setRange(self.min, self.max)
- counter.setSingleStep(self.step)
- counter.setDecimals(0)
- layout.addWidget(counter)
self.setLayout(layout)
- def setupSlider(self):
+ class Dial(QtGui.QDial):
+ """ Creates the range using a dial """
+ def __init__(self, parent, range, slot):
+ QtGui.QDial.__init__(self, parent)
+ self.setRange(range.min, range.max)
+ self.setSingleStep(range.step)
+ self.setNotchesVisible(True)
+ self.setValue(range.default)
+ self.valueChanged.connect(slot)
+
+ class Slider(QtGui.QSlider):
""" Creates the range using a slider """
-
- layout = Qt.QHBoxLayout()
- slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
- slider.setFocusPolicy(QtCore.Qt.NoFocus)
- slider.setRange(self.min, self.max)
- slider.setPageStep(self.step)
- slider.setSingleStep(self.step)
- slider.setTracking(False)
- slider.setInvertedControls(True)
- layout.addWidget(slider)
- self.setLayout(layout)
-
- def init_dial(self):
- layout = Qt.QHBoxLayout()
- dial = QtGui.QDial(self)
- dial.setRange(min, max)
- dial.setSingleStep(step)
- dial.setNotchesVisible(True)
- dial.setValue(init_value)
- layout.addWidget(dial)
- self.setLayout(layout)
+ def __init__(self, parent, range, slot):
+ QtGui.QSlider.__init__(self, QtCore.Qt.Horizontal, parent)
+ self.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.setRange(range.min, range.max)
+ self.setValue(range.default)
+ self.setPageStep(range.step)
+ self.setSingleStep(range.step)
+ self.setTracking(False)
+ self.setInvertedControls(True)
+ self.valueChanged.connect(slot)
+
+ class Counter(QtGui.QDoubleSpinBox):
+ """ Creates the range using a counter """
+ def __init__(self, parent, range, slot):
+ QtGui.QDoubleSpinBox.__init__(self, parent)
+ self.setRange(range.min, range.max)
+ self.setValue(range.default)
+ self.setSingleStep(range.step)
+ self.setDecimals(0)
+ self.valueChanged.connect(slot)
+
+ class CounterSlider(QtGui.QWidget):
+ """ Creates the range using a counter and slider """
+ def __init__(self, parent, range, slot):
+ QtGui.QWidget.__init__(self, parent)
+
+ # Need another horizontal layout
+ layout = Qt.QHBoxLayout()
+
+ # Create a slider with the top-level widget as the parent
+ slider = QtGui.QSlider(QtCore.Qt.Horizontal, self)
+ slider.setFocusPolicy(QtCore.Qt.NoFocus)
+ slider.setRange(range.min, range.max)
+ slider.setValue(range.default)
+ slider.setPageStep(range.step)
+ slider.setSingleStep(range.step)
+ slider.setTracking(False)
+ slider.setInvertedControls(True)
+ layout.addWidget(slider)
+
+ # Setup the counter
+ counter = QtGui.QDoubleSpinBox(self)
+ counter.setRange(range.min, range.max)
+ counter.setValue(range.default)
+ counter.setSingleStep(range.step)
+ counter.setDecimals(0)
+ layout.addWidget(counter)
+
+ # Wire the events to each other
+ counter.valueChanged.connect(slider.setValue)
+ slider.valueChanged.connect(counter.setValue)
+ counter.valueChanged.connect(slot)
+ slider.valueChanged.connect(slot)
+
+ self.setLayout(layout)
- [Commit-gnuradio] [gnuradio] branch master updated (3061e47 -> 04faaba), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 05/05: qtgui: remove dependency mentions of PyQWT., git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 03/05: qt-gui: updating range, counter now shows decimals, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 01/05: qtgui: Initial removal of pyqwt. Replaced with pyqt4., git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 02/05: qtgui: Replaced pyqwt range block with working pyqt version.,
git <=
- [Commit-gnuradio] [gnuradio] 04/05: qtgui: counter_slider now respond to each other without error, git, 2015/04/02