[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 03/05: qt-gui: updating range, counter now
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 03/05: qt-gui: updating range, counter now shows decimals |
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 df148e691ad261a267f15a684b7420d0657f8e45
Author: Bill Clark <address@hidden>
Date: Thu Apr 2 13:27:53 2015 -0400
qt-gui: updating range, counter now shows decimals
---
gr-qtgui/python/qtgui/range.py | 81 +++++++++++++++++++++---------------------
1 file changed, 41 insertions(+), 40 deletions(-)
diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py
index 7a647bd..b2be448 100755
--- a/gr-qtgui/python/qtgui/range.py
+++ b/gr-qtgui/python/qtgui/range.py
@@ -24,94 +24,93 @@
from PyQt4 import Qt, QtCore, QtGui
class Range(object):
- def __init__(self, min, max, step, default):
- self.min = min
- self.max = max
- self.step = step
- self.default = default
+ def __init__(self, minv, maxv, step, default):
+ self.min = float(minv)
+ self.max = float(maxv)
+ self.step = float(step)
+ self.default = float(default)
+ self.find_precision()
+
+ def find_precision(self):
+ temp = str(float(self.step)-int(self.step))[2:]
+ if len(temp) > 15:
+ self.precision = 15
+ else:
+ self.precision = len(temp)
class RangeWidget(QtGui.QWidget):
- def __init__(self, range, slot, label, style):
+ def __init__(self, ranges, slot, label, style):
""" Creates the QT Range widget """
QtGui.QWidget.__init__(self)
- self.range = range
+ self.range = ranges
layout = Qt.QHBoxLayout()
label = Qt.QLabel(label)
layout.addWidget(label)
if style == "dial":
- layout.addWidget(self.Dial(self, range, slot))
+ layout.addWidget(self.Dial(self, self.range, slot))
elif style == "slider":
- layout.addWidget(self.Slider(self, range, slot))
+ layout.addWidget(self.Slider(self, self.range, slot))
elif style == "counter":
- layout.addWidget(self.Counter(self, range, slot))
+ layout.addWidget(self.Counter(self, self.range, slot))
elif style == "counter_slider":
- layout.addWidget(self.CounterSlider(self, range, slot))
+ layout.addWidget(self.CounterSlider(self, self.range, slot))
else:
- layout.addWidget(self.CounterSlider(self, range, slot))
+ layout.addWidget(self.CounterSlider(self, self.range, slot))
self.setLayout(layout)
class Dial(QtGui.QDial):
""" Creates the range using a dial """
- def __init__(self, parent, range, slot):
+ def __init__(self, parent, ranges, slot):
QtGui.QDial.__init__(self, parent)
- self.setRange(range.min, range.max)
- self.setSingleStep(range.step)
+ self.setRange(ranges.min, ranges.max)
+ self.setSingleStep(ranges.step)
self.setNotchesVisible(True)
- self.setValue(range.default)
+ self.setNotchTarget(ranges.step)
+ self.setValue(ranges.default)
self.valueChanged.connect(slot)
class Slider(QtGui.QSlider):
""" Creates the range using a slider """
- def __init__(self, parent, range, slot):
+ def __init__(self, parent, ranges, 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.setRange(ranges.min, ranges.max)
+ self.setValue(ranges.default)
+ self.setPageStep(ranges.step)
+ self.setSingleStep(ranges.step)
+ self.setTickInterval(ranges.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):
+ def __init__(self, parent, ranges, slot):
QtGui.QDoubleSpinBox.__init__(self, parent)
- self.setRange(range.min, range.max)
- self.setValue(range.default)
- self.setSingleStep(range.step)
- self.setDecimals(0)
+ self.setRange(ranges.min, ranges.max)
+ self.setValue(ranges.default)
+ self.setSingleStep(ranges.step)
+ self.setDecimals(ranges.precision)
self.valueChanged.connect(slot)
class CounterSlider(QtGui.QWidget):
""" Creates the range using a counter and slider """
- def __init__(self, parent, range, slot):
+ def __init__(self, parent, ranges, 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)
+ slider = RangeWidget.Slider(parent,ranges,slot)
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)
+ counter = RangeWidget.Counter(parent,ranges,slot)
layout.addWidget(counter)
# Wire the events to each other
@@ -121,3 +120,5 @@ class RangeWidget(QtGui.QWidget):
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 <=
- [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, 2015/04/02
- [Commit-gnuradio] [gnuradio] 04/05: qtgui: counter_slider now respond to each other without error, git, 2015/04/02