# Changing GUI structure on the fly

**URL:** <https://www.ruby-forum.com/t/changing-gui-structure-on-the-fly/243226>\
**Category:** GNU Radio\
**Created:** [September 2, 2015, 4:55pm UTC](https://www.ruby-forum.com/t/changing-gui-structure-on-the-fly/243226 "2015-09-02T16:55:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [September 2, 2015, 4:55pm UTC](https://www.ruby-forum.com/t/changing-gui-structure-on-the-fly/243226/1 "2015-09-02T16:55:13Z")

</div>

Hello

I have a question: I have to program one application, that will switch  
between about 20 modulations.  
With 20 modulations, program will have a lot of parameters to change, so  
GUI needs to change during runtime.

Is it possible to do somethink like that ??  
Are there any design patterns for problem like this ?

Many thanks  
Przemek L.

---

<div class="post-metadata">

**Author:** ![przemek\_l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ce73a5/32.png) [@przemek\_l](https://www.ruby-forum.com/u/przemek_l)\
**Post date:** [September 2, 2015, 5:51pm UTC](https://www.ruby-forum.com/t/changing-gui-structure-on-the-fly/243226/2 "2015-09-02T17:51:53Z")

</div>

Hi Przemek,

this might leave the kind of things that you can “easily” do with the  
GUI tools in the GNU Radio companion. If you want to keep things in the  
GRC, I’d recommend using different taps for the different groups of  
widgets.  
Basically, if you use the QT GUI stuff, you should be able to integrate  
the GUI tools into an Qt application that you might design with Qt  
Creator etc. I must admit that I haven’t tried to build complex GUI  
applications with GR myself, so I can only point you to what I guess  
needs to be done, based on what I did a while back myself with something  
not-GR related:

- build your flow graph with QtGUI visualizations; generate the python  
file. Open that file.
- comment out all the GUI building stuff, ie. all after  
self.setWindowTitle(…) and before self.settings=…
- build your GUI with QtCreator (Qt4, not 5!)[1]; add one of the Layouts  
(e.g. QHBoxLayout, by dragging “Horizontal Layout” onto your form) for  
your visualizations. Save.
- Use pyuic4 to convert the .ui file to a python module. You’ll get a  
class with a setupUi method
- import that module in your python file. Instantiate the class, e.g.  
myForm = Ui\_Form()
- set up the GUI by doing myForm.setupUi(self) where you formerly  
commented out the GUI building stuff
- find the places where “addWidget” was generated by GRC. Replace the  
things to which your QtWidgets are added by the appropriate  
Layout/Container instances from your Qt Form (e.g. the name of your  
QHBoxLayout above)
- hope for the best 🙂

Maybe someone who actually did more work with PyQT can comment on this.

Best regards,  
Marcus

[1] creating the form should look something like:  
Form creation dialog
