I have an application engine where in-program communication is done using PyPubSub.
Planned is a somewhat responsive GUI that e.g. enables/disables widgets based on the model state. This would be implemented using wxPython.
As wxPython has as an own pubsub lib (which is PyPubSub) that works across the GUI, question is: how to maintain the MVC model.
Is it possible (and more importantly: does it make sense) to mix the two messaging systems while maintaining the MVC pattern? E.g. to keep these two messaging systems separate while enabling the GUI having subscribers to the topics of the engine?
Or shall I just use the model's (that is, the app engine's) pubsub within the GUI and not use the wxPython built-in one?
Any help is appreciated on this rather conceptual question.
Summary (by author of pypubsub): if you import from pypubsub instead of wx.lib.pubsub, everything will work, you will not have "two messaging systems".
Details:
There is nothing in the wx package that actually uses wx.lib.pubsub; the latter is still in wx.lib only for legacy reasons (see below), and it is entirely your choice whether you want to make use of publish-subscribe in your wxPython application.
History of pypubsub/wx.lib.pubsub: The wx.lib.pubsub was originally a module developed for wxPython and included in its source code. It was moved out as a standalone library called pypubsub (over 10 years ago!), since nothing in wxPython depended on it, and vice versa. For backwards compatibility, wx.lib.pubsub was kept alive as a specific "release" of the standalone pypubsub (for example, wxPython 3 used pypubsub 3.3). However the latest wxPython (4.0.4) has deprecated its wx.lib.pubsub: you should instead install standalone pypubsub directly from pip install or github, and use from pubsub import pub
(instead of from wx.lib.pubsub import pub
).
If you can, you should use wxPython 4.0.4, Python 3.7, and pypubsub 4.0.0 (4.0.1 will be coming out soon and support keyword-only args).