The Atom api is a library used by Enaml to implement MVC. Change an atom var, and the UI is updated. Change it in the UI and your model gets updated.
I would like to put an Atom var (Bool() in this case) into a dictionary and later update that var
from atom.api import Atom,Bool
class MyModel(Atom):
myBool = Bool()
def getDict(self):
return {'mybool':self.myBool}
def setAllBoolsTrue(self):
self.myBool = True #example to show that just setting mybool will update UI components that use it
#now to show how I'd like to generalize to many components
for k,v in self.getDict().iteritems():
v = True # this fails, even though the id(v) is the same as id(self.mybool)
The last statement fails to update mybool, it just makes a simple assignment.
So is there a way to update the Bool() retrieved from a dictionary in the same way that simply setting it does?
edit: code updated so no syntax errors.
edit: As per suggestions in the comments, I tried without success:
tempDict = self.getDict();
#self.myBool = True # this works
tempDict['mybool'] = True #this does not work