Search code examples
python-2.7user-interfacemodel-view-controllerwxpythonini

wxPython using a Config File INI in Model View GUI


Not exactly sure how to title the question, sorry if it doesn't make sense.

Here it goes.

I am trying to implement a GUI using the model view style

http://wiki.wxpython.org/ModelViewController

Currently I have a settings.ini file that I am importing and saving the sections information to some variables.

simply:

settings.ini

[GENERAL SETTINGS]
file name : Test.csv

main.py

file_name = get_section_values["GENERAL SETTINGS"]["Test.csv"]

Now when I want to change the file_name using the GUI I need to tell it to reload the settings. This breaks the Model-View style.

There are a lot more settings than just the file name that I would like to be able to change in the GUI.

What I am thinking about doing is loading them as I need them so if I change the settings in my GUI, the model will always use the most updated settings. However, I'm not sure if that would be the best way to do it.

Thank you, if you need me to clarify tell me which part.


Solution

  • I'm not sure how this breaks the MVC style. You just put the actions in your controller. So you put the Create, Update, Delete stuff in the controller piece of your code. Then you can have the controller update the view and the model.

    Each time you load your script (or a dialog or whatever), you can re-read the file if you think it's been changed. Otherwise you can just cache the settings.