Search code examples
pythonpyqtqpushbutton

Switching between information widgets using buttons


I am creating a main window with PyQT for the automation of a room full of equipment. I would like the window to have a lateral screen which shows general parameters of all the equipment but, when I click a button related to one particular device, this lateral screen would show its particular configurations (like the temperature of a fridge, for example), very much like PyQT's own property editor.

Does anyone knows which widget should I use for this lateral window and how could I link it to other buttons to make it show different information according to the selected equipment? The closest I got to it is the tab widget, but it isn't exactly what I want yet, as I can't put a button that selects the right tab anywhere I want on the screen.

I hope my question is clear.

added mockup images to try and make it clear. The first image shows the lateral menu (as I want it to be) for a room with coffee machine, lamp, deadly laser, and fridge as equipments. As I click one of the buttons, say, the Deadly Laser one, the lateral menu would change to what is shown in the second image: the particular configurations of the laser. And so on for the fridge, the lamp, the coffee machine, etc.

Menu with no particular equipment selected, thus showing general configurations

Menu with the deadly laser selected


Solution

  • I suggest you use a QStackedWidget for the lateral widget. Then put the buttons in a QButtonGroup, using the relevant page-index of the stacked-widget for each button id. You can then connect the buttongroup.idClicked signal to the stackedwidget.setCurrentIndex slot, to switch between the pages of your lateral widget.