mardi 24 mars 2015

Python MVC just for wx gui -- if not it, then what?

I have been spending time reorganizing a project gui. Originally, I had a file with functions like "makeConfigWindow" and "makeMainWindow" and they did everything to make the windows. The problem was that it was very tightly coupled and very specific, reusable code was nowhere for similar tasks. I decided to try MVC with just the gui portion so I made a model class, view class, and controller class in one interface file. One instance of each per wx.App (except view, that's a new one every new Frame).


The problem I'm running into now is that I seem to be reinventing the wheel. My model simply grabs info from the config file and spits it out when requested, but this functionality was already there by directly referencing the config file. The view, which is a subclass of wx.Frame, ended up having a bunch of functions like "changeBgColor(panel, color)" which was called by the controller -- the problem is that the controller could simply call those functions from wx instead of the View middleman. And now, the controller has ended up looking just as specific as my original "makeMainWindow" functions.


It looks like the MVC framework was already there for this -- the config was the model, wxPython itself was the view, and the enormous command-after-command script was the controller. Correct?


My question is this: if not this way, then how should I go about structuring my gui? My biggest issue is that the gui ends up holding everything, objects, references, everything, because Mainloop is the only thing running in the end, minus a few threads doing system checks and the like, and then they throw events to the gui.


Aucun commentaire:

Enregistrer un commentaire