- setup controls
- do layout
- _persistMgr.RegisterAndRestoreAll
but I like to do:
- setup controls
- _persistMgr.RegisterAndRestoreAll
- if nothing restored:
- do layout
But I can't figure out how to ask _persistMgr if there is something to be restored.
Looking at the doc.Usage section I see this code:
if not PM.PersistenceManager.RegisterAndRestore(book):
# Nothing was restored, so choose the default page ourselves
book.SetSelection(0)
So, I thought I could patch RegisterAndRestoreAll but the call to RegisterAndRestore in there always returns True for me.
- setup controls
- do layout
- _persistMgr.RegisterAndRestoreAll
but I like to do:
- setup controls
- _persistMgr.RegisterAndRestoreAll
- if nothing restored:
- do layout
But I can't figure out how to ask _persistMgr if there is something to be
restored.
Looking at the doc.Usage section I see this code:
if not PM.PersistenceManager.RegisterAndRestore(book):
# Nothing was restored, so choose the default page ourselves
book.SetSelection(0)
So, I thought I could patch RegisterAndRestoreAll but the call to
RegisterAndRestore in there always returns True for me.
Appreciate any hints on this.
I think it's a bug in the Restore method in PersistentManager. Instead
of simply being:
self._persistentHandler.Restore()
It should be:
return self._persistentHandler.Restore()
Could you please check and see if it works this way?
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
I think it's a bug in the Restore method in PersistentManager. Instead
of simply being:
self._persistentHandler.Restore()
It should be:
return self._persistentHandler.Restore()
Could you please check and see if it works this way?
Thanks for the quick reply.
Attached a patch with the changes I made.
Not sure about the change in RegisterAndRestoreAll, it works but it doesn't
look right/nice.
I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.
Could you please see if the patch does what you need?
Thank you!
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.
Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which meant that _hasRestored would get reset.
I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.
Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which
meant that _hasRestored would get reset.
Thanks, I must be getting too old to keep up with this stuff
I'll upload the new patch when I get home tonight.
Thank you!
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.
Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which
meant that _hasRestored would get reset.
Thanks, I must be getting too old to keep up with this stuff
Or maybe trying to do too many things at the same time;-)
I'll upload the new patch when I get home tonight.
Subject:
Re: [wxPython-users] wx.lib.agw.persist
Date:
Tue, 04 Dec 2012 12:07:06 +0100
From:
Werner
Reply-To:
To: werner.bruhin@sfr.frwxpython-users@googlegroups.comwxpython-users@googlegroups.com
Hi Andrea,
On 03/12/2012 22:26, Andrea Gavana wrote:
...
> I have applied a slightly modified version of your patch, which now
> sets an attribute (self._hasRestored) to True if anything was restored
> by PersistenceManager. You can use the HasRestored() method of
> PersistenceManager to check if anything was restored or not.
>
> Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which meant that _hasRestored would get reset.
Werner
-- To unsubscribe, send email to or visit
Hi Andrea,
On 03/12/2012 22:26, Andrea Gavana wrote:
...
> I have applied a slightly modified version of your patch, which now
> sets an attribute (self._hasRestored) to True if anything was restored
> by PersistenceManager. You can use the HasRestored() method of
> PersistenceManager to check if anything was restored or not.
>
> Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which meant that _hasRestored would get reset.
Werner
-- To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)
Sorry didn’t notice that, so you only partially applied it:)
The difference is the following line at the beginning of the method:
self._hasRestored = False
Werner
···
On 17/12/2012 15:02, Andrea Gavana
wrote:
Hi Werner,
On 17 December 2012 15:00, Werner wrote:
Hi Andrea,
It looks like this has not yet made it into SVN
;-)