Hello,
I would not change variables in the configuration data during run-time. Instead I would declare the needed variables separately.
There are several ways possible to make them persistent
- the class eg.PersistentData
- database (like sqlite3)
- python module shelve
- python module pickle
...others
Earlier this was the easiest and worked fine but with new Windows version and the rights you are running EG with, it may not work for you
First is to declare your persistent variables like this:
Code: Select all
class MyPersistentVariables(eg.PersistentData):
myVar1 = 'nothing'
myVar2 = 'anything'
myVar3 = False
During run-time you can set new values:
Code: Select all
def SomeFunction(self):
MyPersistentVariables.myVar1 = 'Changed Value' #How do I persist this change between eg restarts?
If you still would like or need to assign a new value to one of your other variables, you can do it at any time, even at start-up
Code: Select all
def __start__(self):
self.myvar = MyPersistentVariables.myVar1
Disadvantages I have experienced is when running EG under later versions of Windows (from 7 and up) is that EG might fail to update its configuration. But it might work for you. If not I suggest that you check the other alternatives already from start. Google for python shelve or jump start using a database from scratch (my choice).