Python Forum
request help putting together multiple widgets in pyqt application - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code Review (https://python-forum.io/forum-46.html)
+--- Thread: request help putting together multiple widgets in pyqt application (/thread-33858.html)



request help putting together multiple widgets in pyqt application - Oolongtea - Jun-02-2021

Hello people,

I'd like to share some code for review. I am currently working on an interface that will be part of the frontend of some measurement setup, unfortunately I am really struggling to put everything together when adding more widgets.
I've written a mock-up of one part to keep things simple Uronchaa/Graphdisplay

At this point the code in the main branch displays
  • a number of input channels with the possibility to change their names and status (on or off)
  • A graph that displays the names and measurement values of all active channels
  • a push button to add new "measurement" values to all channels

In an effort to separate the business logic from the GUI, mainly to avoid binding everything to Pyqt, I've been trying to organize my code the following way:
  • Widgets dedicated to UI only tasks will carry their own business logic in their class ("usual" Pyqt style)
  • Widgets interacting with the non-UI parts (main models, calculations, etc) will do so via a controller
  • Pyqt signals are for UI related events only, and for UI-to-controller notifications
  • Non UI events (mainly model changes) go through an observer pattern

My end goal is to expand the functionalities with new widgets to modify or display the contents of the underlying data models but my previous attempts seemed too complex or impractical.

Could i please have some feedback or tips on what I have written so far in the main branch? Mainly focusing on the structure of the program, and how the different parts communicate with one another. It would help to know if I am going in the right direction or not.