I have one python file which is responsible for optionparsing, setting up some stuff and then starting the gui. The gui itself and some helper functions are in another python file.
file1.py:
myConf = None
if __name__ == "__main__":
confFileName = HOME+"/test/.conf"
myConf = Config()
print(myConf) # works as expected
run() # this starts the gui
file2.py
from file1 import myConf
...somestuff...
def on_clicked( self, widget ):
mappings = myConf.GetMappings()
As soon as the on_clicked callback is triggered I get an exception:
AttributeError: 'NoneType' object has no attribute 'GetMappings'
This means the myConf which is used in file2 is not yet initialized. However, the gui is set up AFTER myCOnf has been initialized in file1. I want myConf to be a global object which stores information which then every other file can access during runtime.
Whats wrong? Why is it not working as intended?
Has file2 its own copy of the symbol whoch has not been initialized?