May-09-2021, 08:23 PM
I'd like some insight on how to structure a PyQt GUI architecture in a way that decouples the GUI from the underlying business logic.
My understanding of PyQt is that the Views also act as a controller, and any event handling must go through QObjects (and subclasses). This seems straightforward for gui related stuff, but most of the examples I have seen also rely on PyQt for the event handling in the models and such. I must say I'm not really a fan of having such a close coupling between core elements of my program and the gui architecture.
My approach would be to use PyQt signals for gui related elements only, and use an observer pattern (or similar like pubsub) for the other parts of the program. This would separate the models from anything PyQt, with the downside of having to implement controllers that subscribe to both gui signals and business logic events in order to bring the two parts together.
Is it okay to do this, or am I going in the wrong direction?
My understanding of PyQt is that the Views also act as a controller, and any event handling must go through QObjects (and subclasses). This seems straightforward for gui related stuff, but most of the examples I have seen also rely on PyQt for the event handling in the models and such. I must say I'm not really a fan of having such a close coupling between core elements of my program and the gui architecture.
My approach would be to use PyQt signals for gui related elements only, and use an observer pattern (or similar like pubsub) for the other parts of the program. This would separate the models from anything PyQt, with the downside of having to implement controllers that subscribe to both gui signals and business logic events in order to bring the two parts together.
Is it okay to do this, or am I going in the wrong direction?