Package vqt :: Module saveable
[hide private]
[frames] | no frames]

Source Code for Module vqt.saveable

 1  import json 
 2   
3 -class SaveableWidget(object):
4 ''' 5 Inherited by widgets that want to save and restore settings. 6 7 Implement vqGetSaveState/vqSetSaveState. 8 '''
9 - def vqSaveState(self, settings, name):
10 state = self.vqGetSaveState() 11 settings.setValue(name, json.dumps(state))
12
13 - def vqRestoreState(self, settings, name):
14 qstate = settings.value(name) 15 if qstate.isNull(): 16 return 17 18 try: 19 state = json.loads(str(qstate.toString())) 20 self.vqSetSaveState(state) 21 except Exception, e: 22 print('failed to restore %s: %s' % (name,e))
23
24 - def vqGetSaveState(self):
25 return None
26
27 - def vqSetSaveState(self, state):
28 return None
29