I would suggest what you're after is the Model-View-Controller pattern. Your settings file is the canonical repository of the configuration and is the Model. The Configuration class is the Controller and is able to read/update the Model. The GUI is just a View over the Model, and should only do things using the Controller's API. Alternatively, you blur the lines a bit and say the Configuration class is both the Model and the Controller. Or you blur them differently and say the GUI class is one of many possible Controllers and a View for this Model.
Plenty of people will argue that your Model has to be an object-oriented wrapper around your data and must therefore be a class itself. Doesn't bother me, but I'd just use a sensible data layout in the settings file (JSON, XML, INI, whatever) and call it a day. Another worthwhile thing to look at is specific libraries that read/write config files. If you use one of these you effectively get your settings file as an object in memory, and the API to manipulate it. That's your Controller straight up without having to do any work. You'd then ditch your Configuration class entirely, since the in-memory representation of the settings file provides everything you need. Be aware that "MVC" must be one of the most over-used and over-argued-about acronyms of all times, so searching Stack Overflow for it will get you nowhere. Cheers, Tom On 8 May 2017 at 14:34, David Crisp <[email protected]> wrote: > A problem in two parts with their own questions. What is the terminology > for something, and then how would I do it. > > My problem is that I don't know the correct Pythonic (or even general > programming terminology) term to use to search for what I am trying to do. > This makes it very difficult to go searching for the answer to my problem. > > What is the correct terminology for the following: > > I have a Main class that instantiates a Configuration class that handles > reading the settings file and then setting up properties. The same main > class then calls a mainWindow GUI which has a configuration gui that I > want to be able to use and set the properties in the Configuration > class. I not sure what this terminology is. > > For what its worth, I am using PySide, converting the .ui files to python > files and handling the gui content in python instead of the .ui file if > that helps. > > In the following example each of the python files contain a single class. > (makes for a lot of files but it seems to work in my head) > > Main -\ > | Configuration > |- guiMainWindow -\ > | > \--guiConfigWindow > > Given that: > How do I set it up so that the properties set in the configuration class > can be accessed and set by the guiConfigWindow class? > > Mind you, if I know what the correct terminology is and can find some > well written examples I will have this problem solved before you can say > "We needed this code last Friday, Today was meant to be release day" > > I asked on StackOverflow a while ago but haven't had any responses. > David > > > _______________________________________________ > melbourne-pug mailing list > [email protected] > https://mail.python.org/mailman/listinfo/melbourne-pug > >
_______________________________________________ melbourne-pug mailing list [email protected] https://mail.python.org/mailman/listinfo/melbourne-pug
