[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10878 - gnuradio/trunk/gr-qtgui/src/python
From: |
trondeau |
Subject: |
[Commit-gnuradio] r10878 - gnuradio/trunk/gr-qtgui/src/python |
Date: |
Fri, 17 Apr 2009 21:14:34 -0600 (MDT) |
Author: trondeau
Date: 2009-04-17 21:14:34 -0600 (Fri, 17 Apr 2009)
New Revision: 10878
Added:
gnuradio/trunk/gr-qtgui/src/python/qt_digital_window.ui
Modified:
gnuradio/trunk/gr-qtgui/src/python/qt_digital.py
Log:
Using qt's designer program to build an interface from the .ui file. This makes
qt_digital.py example look much better.
Modified: gnuradio/trunk/gr-qtgui/src/python/qt_digital.py
===================================================================
--- gnuradio/trunk/gr-qtgui/src/python/qt_digital.py 2009-04-18 02:24:06 UTC
(rev 10877)
+++ gnuradio/trunk/gr-qtgui/src/python/qt_digital.py 2009-04-18 03:14:34 UTC
(rev 10878)
@@ -6,74 +6,48 @@
import sys, sip
import scipy
-class dialog_box(QtGui.QWidget):
- def __init__(self, display_tx, display_rx, channel):
- QtGui.QWidget.__init__(self, None)
- self.setWindowTitle('Digital Signal Examples')
+try:
+ from qt_digital_window import Ui_DigitalWindow
+except ImportError:
+ print "Error: could not find qt_digital_window.py:"
+ print "\t\"pyuic4 qt_digital_window.ui -o qt_digital_window.py\""
+ sys.exit(1)
- self.control = control_panel(channel, self)
-
- hlayout = QtGui.QHBoxLayout()
- hlayout.addWidget(display_tx)
- hlayout.addWidget(display_rx)
- hlayout.setGeometry(QtCore.QRect(0,0,100,100))
-
- vlayout = QtGui.QVBoxLayout()
- vlayout.addLayout(hlayout)
- vlayout.addLayout(self.control.layout, -1)
- #vlayout.addStretch(-1)
-
- self.setLayout(vlayout)
- self.resize(1000, 1000)
-
-class control_panel(QtGui.QWidget):
- def __init__(self, channel, parent=None):
+class dialog_box(QtGui.QMainWindow):
+ def __init__(self, snkTx, snkRx, channel, parent=None):
QtGui.QWidget.__init__(self, parent)
- self.setWindowTitle('Control Panel')
+ self.gui = Ui_DigitalWindow()
+ self.gui.setupUi(self)
self.channel = channel
-
- self.layout = QtGui.QFormLayout()
- # Set channel noise
- self.noiseEdit = QtGui.QLineEdit(self)
- self.layout.addRow("Noise Amplitude:", self.noiseEdit)
- self.connect(self.noiseEdit, QtCore.SIGNAL("editingFinished()"),
- self.noiseEditText)
+ # Add the qtsnk widgets to the hlayout box
+ self.gui.sinkLayout.addWidget(snkTx)
+ self.gui.sinkLayout.addWidget(snkRx)
- # Set channel frequency offset
- self.freqEdit = QtGui.QLineEdit(self)
- self.layout.addRow("Frequency Offset:", self.freqEdit)
- self.connect(self.freqEdit, QtCore.SIGNAL("editingFinished()"),
+ # Connect up some signals
+ self.connect(self.gui.noiseEdit, QtCore.SIGNAL("editingFinished()"),
+ self.noiseEditText)
+ self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"),
self.freqEditText)
-
- # Set channel timing offset
- self.timeEdit = QtGui.QLineEdit(self)
- self.layout.addRow("Timing Offset:", self.timeEdit)
- self.connect(self.timeEdit, QtCore.SIGNAL("editingFinished()"),
+ self.connect(self.gui.timeEdit, QtCore.SIGNAL("editingFinished()"),
self.timeEditText)
-
- self.quit = QtGui.QPushButton('Close', self)
- self.layout.addRow(self.quit)
-
- self.connect(self.quit, QtCore.SIGNAL('clicked()'),
- QtGui.qApp, QtCore.SLOT('quit()'))
-
+
def set_noise(self, noise):
self.noise = noise
- self.noiseEdit.setText(QtCore.QString("%1").arg(self.noise))
+ self.gui.noiseEdit.setText(QtCore.QString("%1").arg(self.noise))
def set_frequency(self, freq):
self.freq = freq
- self.freqEdit.setText(QtCore.QString("%1").arg(self.freq))
+ self.gui.freqEdit.setText(QtCore.QString("%1").arg(self.freq))
def set_time_offset(self, to):
self.timing_offset = to
- self.timeEdit.setText(QtCore.QString("%1").arg(self.timing_offset))
+ self.gui.timeEdit.setText(QtCore.QString("%1").arg(self.timing_offset))
def noiseEditText(self):
try:
- noise = self.noiseEdit.text().toDouble()[0]
+ noise = self.gui.noiseEdit.text().toDouble()[0]
self.channel.set_noise_voltage(noise)
self.noise = noise
@@ -82,7 +56,7 @@
def freqEditText(self):
try:
- freq = self.freqEdit.text().toDouble()[0]
+ freq = self.gui.freqEdit.text().toDouble()[0]
self.channel.set_frequency_offset(freq)
self.freq = freq
@@ -91,7 +65,7 @@
def timeEditText(self):
try:
- to = self.timeEdit.text().toDouble()[0]
+ to = self.gui.timeEdit.text().toDouble()[0]
self.channel.set_timing_offset(to)
self.timing_offset = to
@@ -139,12 +113,13 @@
pyRxQt = self.snk_rx.pyqwidget()
pyRx = sip.wrapinstance(pyRxQt, QtGui.QWidget)
- self.main_box = dialog_box(pyTx, pyRx, channel)
- self.main_box.control.set_noise(noise)
- self.main_box.control.set_frequency(fo)
- self.main_box.control.set_time_offset(to)
-
+ self.main_box = dialog_box(pyTx, pyRx, channel);
+ self.main_box.set_noise(noise)
+ self.main_box.set_frequency(fo)
+ self.main_box.set_time_offset(to)
self.main_box.show()
+
+
if __name__ == "__main__":
tb = my_top_block();
Added: gnuradio/trunk/gr-qtgui/src/python/qt_digital_window.ui
===================================================================
--- gnuradio/trunk/gr-qtgui/src/python/qt_digital_window.ui
(rev 0)
+++ gnuradio/trunk/gr-qtgui/src/python/qt_digital_window.ui 2009-04-18
03:14:34 UTC (rev 10878)
@@ -0,0 +1,191 @@
+<ui version="4.0" >
+ <class>DigitalWindow</class>
+ <widget class="QMainWindow" name="DigitalWindow" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1236</width>
+ <height>655</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget" >
+ <widget class="QLineEdit" name="noiseEdit" >
+ <property name="geometry" >
+ <rect>
+ <x>120</x>
+ <y>520</y>
+ <width>113</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="noiseLabel" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>520</y>
+ <width>111</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Noise Amplitude</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="closeButton" >
+ <property name="geometry" >
+ <rect>
+ <x>260</x>
+ <y>580</y>
+ <width>80</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Close</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="freqEdit" >
+ <property name="geometry" >
+ <rect>
+ <x>120</x>
+ <y>550</y>
+ <width>113</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="timeEdit" >
+ <property name="geometry" >
+ <rect>
+ <x>120</x>
+ <y>580</y>
+ <width>113</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="freqLabel" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>550</y>
+ <width>101</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Frequency Offset</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="timeLabel" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>580</y>
+ <width>101</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Timing Offset</string>
+ </property>
+ </widget>
+ <widget class="QFrame" name="sinkFrame" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>1221</width>
+ <height>501</height>
+ </rect>
+ </property>
+ <property name="frameShape" >
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow" >
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QWidget" name="horizontalLayoutWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>1201</width>
+ <height>481</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="sinkLayout" />
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QMenuBar" name="menubar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1236</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile" >
+ <property name="title" >
+ <string>&File</string>
+ </property>
+ <addaction name="actionExit" />
+ </widget>
+ <addaction name="menuFile" />
+ </widget>
+ <widget class="QStatusBar" name="statusbar" />
+ <action name="actionExit" >
+ <property name="text" >
+ <string>E&xit</string>
+ </property>
+ </action>
+ </widget>
+ <tabstops>
+ <tabstop>closeButton</tabstop>
+ <tabstop>noiseEdit</tabstop>
+ <tabstop>freqEdit</tabstop>
+ <tabstop>timeEdit</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>closeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>DigitalWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>322</x>
+ <y>623</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>66</x>
+ <y>561</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>actionExit</sender>
+ <signal>triggered()</signal>
+ <receiver>DigitalWindow</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>617</x>
+ <y>327</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10878 - gnuradio/trunk/gr-qtgui/src/python,
trondeau <=