wx.lib.agw.persist.persistencemanager.PersistentObject¶
PersistentObject
: ABC for anything persistent.
This is the base class for persistent object adapters.
wxPython persistence framework is non-intrusive, i.e. can work with the
classes which have no relationship to nor knowledge of it. To allow this,
an intermediate persistence adapter is used: this is just a simple object
which provides the methods used by PersistenceManager
to save and restore
the object properties and implements them using the concrete class methods.
You may derive your own classes from PersistentObject
to implement persistence
support for your common classes, see Defining Custom Persistent Windows in the
__init__.py file.
Class Hierarchy¶
Methods Summary¶
Default class constructor. |
|
Returns the string uniquely identifying the objects supported by this adapter. |
|
Returns the string uniquely identifying the window we’re associated with |
|
Returns the actual associated window. |
|
Restores the corresponding window settings. |
|
Restore the value saved by |
|
Restore the value saved by |
|
Saves the corresponding window settings. |
|
Save the specified value using the given name, should be used only for |
|
Save the specified value using the given name. |
Class API¶
- class PersistentObject¶
PersistentObject
: ABC for anything persistent.This is the base class for persistent object adapters. wxPython persistence framework is non-intrusive, i.e. can work with the classes which have no relationship to nor knowledge of it. To allow this, an intermediate persistence adapter is used: this is just a simple object which provides the methods used by
PersistenceManager
to save and restore the object properties and implements them using the concrete class methods.You may derive your own classes from
PersistentObject
to implement persistence support for your common classes, see Defining Custom Persistent Windows in the __init__.py file.
Methods¶
- __init__(self, window, persistenceHandler=None)¶
Default class constructor.
- Parameters:
window – an instance of
wx.Window
;persistenceHandler – if not
None
, this should a custom handler derived fromAbstractHandler
.
- GetKind(self)¶
Returns the string uniquely identifying the objects supported by this adapter.
Note
This method is called from
SaveValue
andRestoreValue
and normally returns some short (but not too cryptic) strings, e.g. “Checkbox”.
- GetName(self)¶
Returns the string uniquely identifying the window we’re associated with among all the other objects of the same type.
Note
This method is used together with
GetKind
to construct the unique full name of the object in e.g. a configuration file.
- GetWindow(self)¶
Returns the actual associated window.
- Restore(self)¶
Restores the corresponding window settings.
Note
This method shouldn’t be used directly as it doesn’t respect the global
PersistenceManager.DisableRestoring()
settings, usePersistenceManager
methods with the same name instead.
- RestoreCtrlValue(self, name)¶
Restore the value saved by
SaveCtrlValue
, should be used only for controls data value.- Parameters:
name – the same name as was used by
SaveCtrlValue
.- Returns:
True
if the value was successfully read orFalse
if it was not found or an error occurred.
- RestoreValue(self, name)¶
Restore the value saved by
SaveValue
.- Parameters:
name – the same name as was used by
SaveValue
.- Returns:
True
if the value was successfully read orFalse
if it was not found or an error occurred.
- Save(self)¶
Saves the corresponding window settings.
Note
This method shouldn’t be used directly as it doesn’t respect the global
PersistenceManager.DisableSaving()
settings, usePersistenceManager
methods with the same name instead.
- SaveCtrlValue(self, name, value)¶
Save the specified value using the given name, should be used only for controls data value.
- Parameters:
name – the name of the value in the configuration file;
value – the value to save.
- Returns:
True
if the value was saved orFalse
if an error occurred.
- SaveValue(self, name, value)¶
Save the specified value using the given name.
- Parameters:
name – the name of the value in the configuration file;
value – the value to save.
- Returns:
True
if the value was saved orFalse
if an error occurred.