Is there a way to automatically close a QT graphical sink after a flowgraph is done running? For example, I want to read in samples from a USRP, demodulate and plot the constellation, and then close everything automatically. My flowgraph looks like this:
USRP --> Head --> Demodulator --> QT Constellation Sink
|
--------------> File Sink
The head block stops the processing after a prescribed number of samples, but the QT sink remains open until I manually close it. If I disable graphics I can get this to run how I'd like, but having the option to see the constellation is important for me.
I've initially implemented this using a separate thread with a timer (see below), but it seems like there should be a cleaner way of doing this?
Thanks,
Michael
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
tb.show()
def quitter():
time.sleep(run_time_in_seconds)
qapp.quit()
def quitting():
tb.stop()
tb.wait()
qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
t = Thread(target=quitter)
t.start()
qapp.exec_()