[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/05: qtgui: Initial removal of pyqwt. Rep
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/05: qtgui: Initial removal of pyqwt. Replaced with pyqt4. |
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 cde6a28977dc2affddb76b6f7f1ffff822581c46
Author: Seth Hitefield <address@hidden>
Date: Tue Mar 31 18:39:35 2015 -0700
qtgui: Initial removal of pyqwt. Replaced with pyqt4.
---
gr-qtgui/grc/qtgui_range.xml | 128 ++---------------------------------
gr-qtgui/python/qtgui/CMakeLists.txt | 1 +
gr-qtgui/python/qtgui/__init__.py | 3 +
gr-qtgui/python/qtgui/range.py | 105 ++++++++++++++++++++++++++++
4 files changed, 114 insertions(+), 123 deletions(-)
diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml
index 2896d08..ecbd28a 100644
--- a/gr-qtgui/grc/qtgui_range.xml
+++ b/gr-qtgui/grc/qtgui_range.xml
@@ -8,130 +8,12 @@
<block>
<name>QT GUI Range</name>
<key>variable_qtgui_range</key>
- <import>from PyQt4 import Qt</import>
- <import>from PyQt4.QtCore import QObject, pyqtSlot</import>
- <import>import PyQt4.Qwt5 as Qwt</import>
+ <import>from gnuradio.qtgui import Range</import>
<var_make>self.$(id) = $(id) = $value</var_make>
- <make>#set $win = 'self._%s_layout'%$id
-#if not $label()
- #set $label = '"%s"'%$id
-#end if
-########################################################################
-#if $widget() == "knob"
-########################################################################
-$win = Qt.QVBoxLayout()
-self._$(id)_knob = Qwt.QwtKnob()
-self._$(id)_knob.setRange($start, $stop, $step)
-self._$(id)_knob.setValue(self.$id)
-self._$(id)_knob.valueChanged.connect(self.set_$(id))
-$(win).addWidget(self._$(id)_knob)
-self._$(id)_label = Qt.QLabel($label)
-self._$(id)_label.setAlignment(Qt.Qt.AlignTop | Qt.Qt.AlignHCenter)
-$(win).addWidget(self._$(id)_label)
-#end if
-########################################################################
-#if $widget() == "thermo"
-########################################################################
-$win = Qt.QVBoxLayout()
-self._$(id)_label = Qt.QLabel($label)
-self._$(id)_thermo = Qwt.QwtThermo()
-self._$(id)_thermo.setScalePosition(Qwt.QwtThermo.$orient.scalepos)
-self._$(id)_thermo.setRange($start, $stop)
-self._$(id)_thermo.setValue(self.$id)
-self._$(id)_thermo.$(orient.minfcn)($min_len)
-#if 'horizontal' in $orient().lower()
-self._$(id)_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
-$(win).addWidget(self._$(id)_label)
-$(win).addWidget(self._$(id)_thermo)
-#elif 'vertical' in $orient().lower()
-self._$(id)_label.setAlignment(Qt.Qt.AlignTop)
-$(win).addWidget(self._$(id)_thermo)
-$(win).addWidget(self._$(id)_label)
-#end if
-#end if
-########################################################################
-#if $widget() == "counter"
-########################################################################
-$win = Qt.QHBoxLayout()
-$(win).addWidget(Qt.QLabel($label+": "))
-class qwt_counter_pyslot(Qwt.QwtCounter):
- def __init__(self, parent=None):
- Qwt.QwtCounter.__init__(self, parent)
- @pyqtSlot('double')
- def setValue(self, value):
- super(Qwt.QwtCounter, self).setValue(value)
-self._$(id)_counter = qwt_counter_pyslot()
-self._$(id)_counter.setRange($start, $stop, $step)
-self._$(id)_counter.setNumButtons(2)
-self._$(id)_counter.setMinimumWidth($min_len)
-self._$(id)_counter.setValue(self.$id)
-$(win).addWidget(self._$(id)_counter)
-self._$(id)_counter.valueChanged.connect(self.set_$(id))
-#end if
-########################################################################
-#if $widget() == "slider"
-########################################################################
-$win = Qt.QVBoxLayout()
-self._$(id)_label = Qt.QLabel($label)
-self._$(id)_slider = Qwt.QwtSlider(None, Qt.$orient,
Qwt.QwtSlider.$orient.scalepos, Qwt.QwtSlider.BgSlot)
-self._$(id)_slider.setRange($start, $stop, $step)
-self._$(id)_slider.setValue(self.$id)
-self._$(id)_slider.$(orient.minfcn)($min_len)
-self._$(id)_slider.valueChanged.connect(self.set_$(id))
-#if 'horizontal' in $orient().lower()
-self._$(id)_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
-$(win).addWidget(self._$(id)_label)
-$(win).addWidget(self._$(id)_slider)
-#elif 'vertical' in $orient().lower()
-self._$(id)_label.setAlignment(Qt.Qt.AlignTop)
-$(win).addWidget(self._$(id)_slider)
-$(win).addWidget(self._$(id)_label)
-#end if
-#end if
-########################################################################
-#if $widget() == "counter_slider"
-########################################################################
-$win = Qt.QVBoxLayout()
-self._$(id)_tool_bar = Qt.QToolBar(self)
-$(win).addWidget(self._$(id)_tool_bar)
-self._$(id)_tool_bar.addWidget(Qt.QLabel($label+": "))
-class qwt_counter_pyslot(Qwt.QwtCounter):
- def __init__(self, parent=None):
- Qwt.QwtCounter.__init__(self, parent)
- @pyqtSlot('double')
- def setValue(self, value):
- super(Qwt.QwtCounter, self).setValue(value)
-self._$(id)_counter = qwt_counter_pyslot()
-self._$(id)_counter.setRange($start, $stop, $step)
-self._$(id)_counter.setNumButtons(2)
-self._$(id)_counter.setValue(self.$id)
-self._$(id)_tool_bar.addWidget(self._$(id)_counter)
-self._$(id)_counter.valueChanged.connect(self.set_$(id))
-self._$(id)_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
-self._$(id)_slider.setRange($start, $stop, $step)
-self._$(id)_slider.setValue(self.$id)
-self._$(id)_slider.setMinimumWidth($min_len)
-self._$(id)_slider.valueChanged.connect(self.set_$(id))
-$(win).addWidget(self._$(id)_slider)
-#end if
-$(gui_hint()($win))</make>
- <callback>self.set_$(id)($value)</callback>
- <callback>#if $widget() == "knob"
-Qt.QMetaObject.invokeMethod(self._$(id)_knob, "setValue", Qt.Q_ARG("double",
$id))
-#end if
-#if $widget() == "thermo"
-Qt.QMetaObject.invokeMethod(self._$(id)_thermo, "setValue", Qt.Q_ARG("double",
$id))
-#end if
-#if $widget() == "counter"
-Qt.QMetaObject.invokeMethod(self._$(id)_counter, "setValue",
Qt.Q_ARG("double", $id))
-#end if
-#if $widget() == "slider"
-Qt.QMetaObject.invokeMethod(self._$(id)_slider, "setValue", Qt.Q_ARG("double",
$id))
-#end if
-#if $widget() == "counter_slider"
-Qt.QMetaObject.invokeMethod(self._$(id)_counter, "setValue",
Qt.Q_ARG("double", $id))
-Qt.QMetaObject.invokeMethod(self._$(id)_slider, "setValue", Qt.Q_ARG("double",
$id))
-#end if</callback>
+ <make>#set $win = 'self._%s'%$id
+$(win) = Range($start, $stop, $step, $value, "$widget")
+$(gui_hint()($win))
+ </make>
<param>
<name>Label</name>
<key>label</key>
diff --git a/gr-qtgui/python/qtgui/CMakeLists.txt
b/gr-qtgui/python/qtgui/CMakeLists.txt
index c3d83f6..4fa4d0f 100644
--- a/gr-qtgui/python/qtgui/CMakeLists.txt
+++ b/gr-qtgui/python/qtgui/CMakeLists.txt
@@ -22,6 +22,7 @@ include(GrPython)
GR_PYTHON_INSTALL(
FILES __init__.py
+ range.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/qtgui
COMPONENT "qtgui_python"
)
diff --git a/gr-qtgui/python/qtgui/__init__.py
b/gr-qtgui/python/qtgui/__init__.py
index e9aeea7..d74d0f2 100644
--- a/gr-qtgui/python/qtgui/__init__.py
+++ b/gr-qtgui/python/qtgui/__init__.py
@@ -26,9 +26,12 @@ Provides a GUI interface using the QT backend.
# The presence of this file turns this directory into a Python package
import os
+
try:
from qtgui_swig import *
except ImportError:
dirname, filename = os.path.split(os.path.abspath(__file__))
__path__.append(os.path.join(dirname, "..", "..", "swig"))
from qtgui_swig import *
+
+from range import Range
diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py
new file mode 100755
index 0000000..1d19818
--- /dev/null
+++ b/gr-qtgui/python/qtgui/range.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright 2015 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from PyQt4 import Qt, QtCore, QtGui
+
+
+class Range(QtGui.QWidget):
+
+ def __init__(self, min, max, step, default, style):
+ QtGui.QWidget.__init__(self)
+
+ 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()
+
+
+ def setupCounterSlider(self):
+ """ Creates the range using a counter and 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)
+
+ 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)
+
+ self.setLayout(layout)
+
+ def setupCounter(self):
+ """ Creates the range using a counter """
+
+ 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):
+ """ 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)
- [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 <=
- [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