I'm writing a program to read comics with a feature to switch between single-page and double-page view. I'm storing this value (and others) inside a config.ini
file, like this:
[settings]
double_view = False
And change it trough a button in my main.py
file:
def single_double(self):
if self.double_page_button.isChecked():
flag = 'True'
else:
flag = 'False'
config['settings']['double_view'] = flag
self.write_config()
My problem is that I also have a module called page_handler.py
that needs to constantly check the value of this variable:
config = ConfigParser()
config.read('config.ini')
double_view = config['settings'].getboolean('double_view')
class MasterPageHandler(SinglePageHandler, DoublePageHandler):
def get_next_page(self):
if not double_view:
return SinglePageHandler.get_next_page()
else:
return DoublePageHandler.get_next_page()
But it seems to only read the config file once when the program starts, so I would have to read it again inside every function that needs to make the same check. This doesn't feel right though, since that would be a lot of reading.
Is that the way to do it? Maybe I am misunderstanding the use of .ini files?