0

I am trying to make a GUI in python using pyqt4 which incorporates a waterfall sink which is connected with an USRP. The problem is that the data should be shown in waterfall sink continuously which makes the GUI to freeze and I can not use the other buttons in meanwhile. I was checking to use threads, but till now what I understood is that in threads I can put just functions which will give an result at the end, but not the functions which will give results continuously and I want to see it in the main GUI.

Any idea how to make it possible to see the continuous results from waterfall sink and not to freeze the main GUI.

Jetmir
  • 21
  • 2
  • Waterfall sink? Could you elaborate a bit? I assume you don't mean you want to display your data in one of these: https://www.google.com.au/search?q=waterfall+sink&tbm=isch – three_pineapples Oct 01 '14 at 12:32
  • You can use Signal and Slot mechanism to continuously update GUI from other thread without blocking main thread. – Fenikso Oct 01 '14 at 16:43
  • This example may give you some ideas: http://stackoverflow.com/a/25723995/674475 – Fenikso Oct 01 '14 at 16:45

2 Answers2

0

There are several ways to do this, but basically either

  1. Breakup your waterfall sink into chunks of work, which the GUI can execute periodically. For example, instead of continuously updating the waterfall sink in a function that GUI calls, have only a "short" update (one "time step"), and have the function return right after; make the function called periodically via QTimer.
  2. Make the waterfall sink execute in a separate thread by using a QObject instantiated in a QThread instance; and make the sink function emit a signal at regular interval, say at every "time step" of the waterfall update.
Oliver
  • 27,510
  • 9
  • 72
  • 103
-1

you can derive a class from QThread. Do your processing in run function and store your data in some data structure. Start this thread from your main thread and take data from this data structure with proper synchronization. This way processing will not freeze your main UI thread.

Some References

Background thread with QThread in PyQt

Example of the right way to use QThread in PyQt?

Community
  • 1
  • 1
Abhishek Bansal
  • 5,197
  • 4
  • 40
  • 69