I'm totally new to Python, and I am trying to figure out a way to store settings. My application (python + pyqt5) stores the settings in a SqLite database. A function loads these settings at startup and sets all the textboxes and checkboxes accordingly.
Based on the settings, my program does have to reacti differently. My program works on multiple threads, and all these threads need to know the pertinent settings. I do not want to access the UI each time I need a setting, i would like to have the value stored in a variable, and have this variable accessible from the whole app. (read only is enough...)
Now, this is what i see in my head, but now I would like to know if this makes even sense, if there is a different way to do it, that is better, if there is something like a "global environment variable" that can be read from everywhere?
I searched online, but was not able to find any information to this.
what options I explored so far:
passing the values to the threads so they have their own "copy" of the settings. This did not work as some functions wait for external input and when they use the settings, they might have been changed and be old.
same as above, but updating the settings with a dedicated signal each time something changes. Works, but has the feeling of reinventing the wheel. There must be a nicer way.
Making a global variable accessibel from everywhere - Would be nice, but couldnt find a way to do this so far.
query the database when needed from every single thread. works, but I dont like it. It feels like slow compared to accessing directly the memory.