From d00fed7b141aa45ae4013aee2b157c11f34fc631 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 23 Sep 2011 17:37:15 -0400 Subject: qtgui: moved actual examples to new examples directory. --- config/grc_gr_qtgui.m4 | 1 + gr-qtgui/Makefile.am | 2 +- gr-qtgui/apps/Makefile.am | 3 - gr-qtgui/apps/pyqt_example_c.py | 150 --------------------------------- gr-qtgui/apps/pyqt_example_f.py | 152 --------------------------------- gr-qtgui/apps/pyqt_time_c.py | 163 ------------------------------------ gr-qtgui/apps/pyqt_time_f.py | 163 ------------------------------------ gr-qtgui/examples/.gitignore | 2 + gr-qtgui/examples/Makefile.am | 34 ++++++++ gr-qtgui/examples/pyqt_example_c.py | 150 +++++++++++++++++++++++++++++++++ gr-qtgui/examples/pyqt_example_f.py | 152 +++++++++++++++++++++++++++++++++ gr-qtgui/examples/pyqt_time_c.py | 163 ++++++++++++++++++++++++++++++++++++ gr-qtgui/examples/pyqt_time_f.py | 163 ++++++++++++++++++++++++++++++++++++ 13 files changed, 666 insertions(+), 632 deletions(-) delete mode 100755 gr-qtgui/apps/pyqt_example_c.py delete mode 100755 gr-qtgui/apps/pyqt_example_f.py delete mode 100755 gr-qtgui/apps/pyqt_time_c.py delete mode 100755 gr-qtgui/apps/pyqt_time_f.py create mode 100644 gr-qtgui/examples/.gitignore create mode 100644 gr-qtgui/examples/Makefile.am create mode 100755 gr-qtgui/examples/pyqt_example_c.py create mode 100755 gr-qtgui/examples/pyqt_example_f.py create mode 100755 gr-qtgui/examples/pyqt_time_c.py create mode 100755 gr-qtgui/examples/pyqt_time_f.py diff --git a/config/grc_gr_qtgui.m4 b/config/grc_gr_qtgui.m4 index ddb7c7ca9..2204e49ae 100644 --- a/config/grc_gr_qtgui.m4 +++ b/config/grc_gr_qtgui.m4 @@ -83,6 +83,7 @@ AC_DEFUN([GRC_GR_QTGUI],[ gr-qtgui/Makefile \ gr-qtgui/gnuradio-qtgui.pc \ gr-qtgui/apps/Makefile \ + gr-qtgui/examples/Makefile \ gr-qtgui/grc/Makefile \ gr-qtgui/lib/Makefile \ gr-qtgui/python/Makefile \ diff --git a/gr-qtgui/Makefile.am b/gr-qtgui/Makefile.am index cc194e4c0..38033e1ac 100644 --- a/gr-qtgui/Makefile.am +++ b/gr-qtgui/Makefile.am @@ -24,7 +24,7 @@ include $(top_srcdir)/Makefile.common SUBDIRS = lib if PYTHON -SUBDIRS += swig python apps grc +SUBDIRS += swig python apps grc examples endif pkgconfigdir = $(libdir)/pkgconfig diff --git a/gr-qtgui/apps/Makefile.am b/gr-qtgui/apps/Makefile.am index 7b35d949e..31450d15c 100644 --- a/gr-qtgui/apps/Makefile.am +++ b/gr-qtgui/apps/Makefile.am @@ -28,9 +28,6 @@ nodist_bin_SCRIPTS = \ usrp_display_qtgui.ui noinst_PYTHON = \ - pyqt_example_f.py \ - pyqt_example_c.py \ - pyqt_time_c.py \ qt_digital.py \ qt_digital_window.py \ usrp2_display.py \ diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py deleted file mode 100755 index 607ab12ee..000000000 --- a/gr-qtgui/apps/pyqt_example_c.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.freq1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.amp1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.freq2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.amp2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.quit.setMinimumWidth(100) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() - channel = gr.channel_model(0.001) - thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) - self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Complex Signal Example", - True, True, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, channel, thr, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - tb.stop() - diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py deleted file mode 100755 index 2d957c85a..000000000 --- a/gr-qtgui/apps/pyqt_example_f.py +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.freq1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.amp1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.freq2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.amp2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.quit.setMinimumWidth(100) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 1000 - f2 = 2000 - - fftsize = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() - thr = gr.throttle(gr.sizeof_float, 100*fftsize) - noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001) - add = gr.add_ff() - self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, Rs, - "Float Signal Example", - True, True, True, False) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, thr, (add,0)) - self.connect(noise, (add,1)) - self.connect(add, self.snk1) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - self.main_box = dialog_box(pyWin, self.ctrl_win) - - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - tb.stop() diff --git a/gr-qtgui/apps/pyqt_time_c.py b/gr-qtgui/apps/pyqt_time_c.py deleted file mode 100755 index fa7d60e81..000000000 --- a/gr-qtgui/apps/pyqt_time_c.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.freq1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.amp1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.freq2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.amp2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.quit.setMinimumWidth(100) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 100 - f2 = 200 - - npts = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_cc() - channel = gr.channel_model(0.01) - thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) - self.snk1 = qtgui.time_sink_c(npts, Rs, - "Complex Time Example", 3) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, channel, thr, (self.snk1, 0)) - self.connect(src1, (self.snk1, 1)) - self.connect(src2, (self.snk1, 2)) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - # Example of using signal/slot to set the title of a curve - pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"), - pyWin, QtCore.SLOT("setTitle(int, QString)")) - pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "Re{sum}") - self.snk1.set_title(1, "Im{Sum}") - self.snk1.set_title(2, "Re{src1}") - self.snk1.set_title(3, "Im{src1}") - self.snk1.set_title(4, "Re{src2}") - self.snk1.set_title(5, "Im{src2}") - - # Can also set the color of a curve - #self.snk1.set_color(5, "blue") - - #pyWin.show() - self.main_box = dialog_box(pyWin, self.ctrl_win) - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - tb.stop() - diff --git a/gr-qtgui/apps/pyqt_time_f.py b/gr-qtgui/apps/pyqt_time_f.py deleted file mode 100755 index 1b9efa10d..000000000 --- a/gr-qtgui/apps/pyqt_time_f.py +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env python - -from gnuradio import gr -from gnuradio import qtgui -from PyQt4 import QtGui, QtCore -import sys, sip - -class dialog_box(QtGui.QWidget): - def __init__(self, display, control): - QtGui.QWidget.__init__(self, None) - self.setWindowTitle('PyQt Test GUI') - - self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) - self.boxlayout.addWidget(display, 1) - self.boxlayout.addWidget(control) - - self.resize(800, 500) - -class control_box(QtGui.QWidget): - def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) - self.setWindowTitle('Control Panel') - - self.setToolTip('Control the signals') - QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) - - self.layout = QtGui.QFormLayout(self) - - # Control the first signal - self.freq1Edit = QtGui.QLineEdit(self) - self.freq1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) - self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), - self.freq1EditText) - - self.amp1Edit = QtGui.QLineEdit(self) - self.amp1Edit.setMinimumWidth(100) - self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) - self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), - self.amp1EditText) - - - # Control the second signal - self.freq2Edit = QtGui.QLineEdit(self) - self.freq2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) - self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), - self.freq2EditText) - - - self.amp2Edit = QtGui.QLineEdit(self) - self.amp2Edit.setMinimumWidth(100) - self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) - self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), - self.amp2EditText) - - self.quit = QtGui.QPushButton('Close', self) - self.quit.setMinimumWidth(100) - self.layout.addWidget(self.quit) - - self.connect(self.quit, QtCore.SIGNAL('clicked()'), - QtGui.qApp, QtCore.SLOT('quit()')) - - def attach_signal1(self, signal): - self.signal1 = signal - self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) - self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) - - def attach_signal2(self, signal): - self.signal2 = signal - self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) - self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) - - def freq1EditText(self): - try: - newfreq = float(self.freq1Edit.text()) - self.signal1.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp1EditText(self): - try: - newamp = float(self.amp1Edit.text()) - self.signal1.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - - def freq2EditText(self): - try: - newfreq = float(self.freq2Edit.text()) - self.signal2.set_frequency(newfreq) - except ValueError: - print "Bad frequency value entered" - - def amp2EditText(self): - try: - newamp = float(self.amp2Edit.text()) - self.signal2.set_amplitude(newamp) - except ValueError: - print "Bad amplitude value entered" - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - Rs = 8000 - f1 = 100 - f2 = 200 - - npts = 2048 - - self.qapp = QtGui.QApplication(sys.argv) - - src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) - src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) - src = gr.add_ff() - thr = gr.throttle(gr.sizeof_float, 100*npts) - noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001) - add = gr.add_ff() - self.snk1 = qtgui.time_sink_f(npts, Rs, - "Complex Time Example", 3) - - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, thr, (add,0)) - self.connect(noise, (add,1)) - self.connect(add, self.snk1) - self.connect(src1, (self.snk1, 1)) - self.connect(src2, (self.snk1, 2)) - - self.ctrl_win = control_box() - self.ctrl_win.attach_signal1(src1) - self.ctrl_win.attach_signal2(src2) - - # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.pyqwidget() - - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - - # Example of using signal/slot to set the title of a curve - pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"), - pyWin, QtCore.SLOT("setTitle(int, QString)")) - pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "sum") - self.snk1.set_title(1, "src1") - self.snk1.set_title(2, "src2") - - # Can also set the color of a curve - #self.snk1.set_color(5, "blue") - - #pyWin.show() - self.main_box = dialog_box(pyWin, self.ctrl_win) - self.main_box.show() - -if __name__ == "__main__": - tb = my_top_block(); - tb.start() - tb.qapp.exec_() - tb.stop() - diff --git a/gr-qtgui/examples/.gitignore b/gr-qtgui/examples/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-qtgui/examples/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-qtgui/examples/Makefile.am b/gr-qtgui/examples/Makefile.am new file mode 100644 index 000000000..a204d1fcc --- /dev/null +++ b/gr-qtgui/examples/Makefile.am @@ -0,0 +1,34 @@ +# +# Copyright 2008-2011 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. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON +ourdatadir = $(exampledir)/qt-gui + +dist_ourdata_SCRIPTS = \ + pyqt_example_c.py \ + pyqt_example_f.py \ + pyqt_time_c.py \ + pyqt_time_f.py +endif + +EXTRA_DIST += diff --git a/gr-qtgui/examples/pyqt_example_c.py b/gr-qtgui/examples/pyqt_example_c.py new file mode 100755 index 000000000..607ab12ee --- /dev/null +++ b/gr-qtgui/examples/pyqt_example_c.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.freq1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.amp1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.freq2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.amp2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.quit.setMinimumWidth(100) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_cc() + channel = gr.channel_model(0.001) + thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize) + self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Complex Signal Example", + True, True, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, channel, thr, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + tb.stop() + diff --git a/gr-qtgui/examples/pyqt_example_f.py b/gr-qtgui/examples/pyqt_example_f.py new file mode 100755 index 000000000..2d957c85a --- /dev/null +++ b/gr-qtgui/examples/pyqt_example_f.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.freq1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.amp1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.freq2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.amp2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.quit.setMinimumWidth(100) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 1000 + f2 = 2000 + + fftsize = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_ff() + thr = gr.throttle(gr.sizeof_float, 100*fftsize) + noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001) + add = gr.add_ff() + self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, Rs, + "Float Signal Example", + True, True, True, False) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, thr, (add,0)) + self.connect(noise, (add,1)) + self.connect(add, self.snk1) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + self.main_box = dialog_box(pyWin, self.ctrl_win) + + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + tb.stop() diff --git a/gr-qtgui/examples/pyqt_time_c.py b/gr-qtgui/examples/pyqt_time_c.py new file mode 100755 index 000000000..fa7d60e81 --- /dev/null +++ b/gr-qtgui/examples/pyqt_time_c.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.freq1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.amp1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.freq2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.amp2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.quit.setMinimumWidth(100) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 100 + f2 = 200 + + npts = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_cc() + channel = gr.channel_model(0.01) + thr = gr.throttle(gr.sizeof_gr_complex, 100*npts) + self.snk1 = qtgui.time_sink_c(npts, Rs, + "Complex Time Example", 3) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, channel, thr, (self.snk1, 0)) + self.connect(src1, (self.snk1, 1)) + self.connect(src2, (self.snk1, 2)) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + # Example of using signal/slot to set the title of a curve + pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"), + pyWin, QtCore.SLOT("setTitle(int, QString)")) + pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "Re{sum}") + self.snk1.set_title(1, "Im{Sum}") + self.snk1.set_title(2, "Re{src1}") + self.snk1.set_title(3, "Im{src1}") + self.snk1.set_title(4, "Re{src2}") + self.snk1.set_title(5, "Im{src2}") + + # Can also set the color of a curve + #self.snk1.set_color(5, "blue") + + #pyWin.show() + self.main_box = dialog_box(pyWin, self.ctrl_win) + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + tb.stop() + diff --git a/gr-qtgui/examples/pyqt_time_f.py b/gr-qtgui/examples/pyqt_time_f.py new file mode 100755 index 000000000..1b9efa10d --- /dev/null +++ b/gr-qtgui/examples/pyqt_time_f.py @@ -0,0 +1,163 @@ +#!/usr/bin/env python + +from gnuradio import gr +from gnuradio import qtgui +from PyQt4 import QtGui, QtCore +import sys, sip + +class dialog_box(QtGui.QWidget): + def __init__(self, display, control): + QtGui.QWidget.__init__(self, None) + self.setWindowTitle('PyQt Test GUI') + + self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self) + self.boxlayout.addWidget(display, 1) + self.boxlayout.addWidget(control) + + self.resize(800, 500) + +class control_box(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.setWindowTitle('Control Panel') + + self.setToolTip('Control the signals') + QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10)) + + self.layout = QtGui.QFormLayout(self) + + # Control the first signal + self.freq1Edit = QtGui.QLineEdit(self) + self.freq1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Frequency:", self.freq1Edit) + self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"), + self.freq1EditText) + + self.amp1Edit = QtGui.QLineEdit(self) + self.amp1Edit.setMinimumWidth(100) + self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit) + self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"), + self.amp1EditText) + + + # Control the second signal + self.freq2Edit = QtGui.QLineEdit(self) + self.freq2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Frequency:", self.freq2Edit) + self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"), + self.freq2EditText) + + + self.amp2Edit = QtGui.QLineEdit(self) + self.amp2Edit.setMinimumWidth(100) + self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit) + self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"), + self.amp2EditText) + + self.quit = QtGui.QPushButton('Close', self) + self.quit.setMinimumWidth(100) + self.layout.addWidget(self.quit) + + self.connect(self.quit, QtCore.SIGNAL('clicked()'), + QtGui.qApp, QtCore.SLOT('quit()')) + + def attach_signal1(self, signal): + self.signal1 = signal + self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency())) + self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude())) + + def attach_signal2(self, signal): + self.signal2 = signal + self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency())) + self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude())) + + def freq1EditText(self): + try: + newfreq = float(self.freq1Edit.text()) + self.signal1.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp1EditText(self): + try: + newamp = float(self.amp1Edit.text()) + self.signal1.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + + def freq2EditText(self): + try: + newfreq = float(self.freq2Edit.text()) + self.signal2.set_frequency(newfreq) + except ValueError: + print "Bad frequency value entered" + + def amp2EditText(self): + try: + newamp = float(self.amp2Edit.text()) + self.signal2.set_amplitude(newamp) + except ValueError: + print "Bad amplitude value entered" + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + Rs = 8000 + f1 = 100 + f2 = 200 + + npts = 2048 + + self.qapp = QtGui.QApplication(sys.argv) + + src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0) + src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0) + src = gr.add_ff() + thr = gr.throttle(gr.sizeof_float, 100*npts) + noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001) + add = gr.add_ff() + self.snk1 = qtgui.time_sink_f(npts, Rs, + "Complex Time Example", 3) + + self.connect(src1, (src,0)) + self.connect(src2, (src,1)) + self.connect(src, thr, (add,0)) + self.connect(noise, (add,1)) + self.connect(add, self.snk1) + self.connect(src1, (self.snk1, 1)) + self.connect(src2, (self.snk1, 2)) + + self.ctrl_win = control_box() + self.ctrl_win.attach_signal1(src1) + self.ctrl_win.attach_signal2(src2) + + # Get the reference pointer to the SpectrumDisplayForm QWidget + pyQt = self.snk1.pyqwidget() + + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + + # Example of using signal/slot to set the title of a curve + pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"), + pyWin, QtCore.SLOT("setTitle(int, QString)")) + pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "sum") + self.snk1.set_title(1, "src1") + self.snk1.set_title(2, "src2") + + # Can also set the color of a curve + #self.snk1.set_color(5, "blue") + + #pyWin.show() + self.main_box = dialog_box(pyWin, self.ctrl_win) + self.main_box.show() + +if __name__ == "__main__": + tb = my_top_block(); + tb.start() + tb.qapp.exec_() + tb.stop() + -- cgit