PersistentControls on wxPython Phoenix: apply correctly Werner's patch and update the docstrings with the example provided by mattip.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73198 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Andrea Gavana
2012-12-17 20:16:04 +00:00
parent 295d3f6442
commit c480c4578c
3 changed files with 23 additions and 17 deletions

View File

@@ -120,7 +120,7 @@ andrea.gavana@maerskoil.com
AGW version: 0.9.7
Last updated: 03 December 2012, 21.00 GMT
Last updated: 17 December 2012, 21.00 GMT
"""

View File

@@ -98,28 +98,36 @@ Usage
Example of using a notebook control which automatically remembers the last open page::
import wx
import wx, os
import wx.lib.agw.persist as PM
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init(self, parent, -1, "Persistent Controls Demo")
wx.Frame.__init__(self, parent, -1, "Persistent Controls Demo")
book = wx.Notebook(self, wx.ID_ANY)
self.book = wx.Notebook(self, wx.ID_ANY)
# Very important step!!
book.SetName("MyBook") # Do not use the default name!!
book.AddPage(wx.Panel(book), "Hello")
book.AddPage(wx.Panel(book), "World")
if not PM.PersistenceManager.RegisterAndRestore(book):
# Nothing was restored, so choose the default page ourselves
book.SetSelection(0)
self.book.SetName("MyBook") # Do not use the default name!!
self.book.AddPage(wx.Panel(self.book), "Hello")
self.book.AddPage(wx.Panel(self.book), "World")
self.Bind(wx.EVT_CLOSE, self.OnClose)
self._persistMgr = PM.PersistenceManager.Get()
_configFile = os.path.join(os.getcwd(), self.book.GetName())
self._persistMgr.SetPersistenceFile(_configFile)
if not self._persistMgr.RegisterAndRestoreAll(self.book):
# Nothing was restored, so choose the default page ourselves
self.book.SetSelection(0)
def OnClose(self, event):
self._persistMgr.SaveAndUnregister(self.book)
event.Skip()
# our normal wxApp-derived class, as usual
@@ -171,7 +179,7 @@ License And Version
`PersistentObjects` library is distributed under the wxPython license.
Latest revision: Andrea Gavana @ 25 Apr 2012, 11.00 GMT
Latest revision: Andrea Gavana @ 17 Dec 2012, 21.00 GMT
Version 0.4.
"""

View File

@@ -10,7 +10,7 @@
# Python Code By:
#
# Andrea Gavana, @ 16 Nov 2009
# Latest Revision: 03 Dec 2012, 21.00 GMT
# Latest Revision: 17 Dec 2012, 21.00 GMT
#
# For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
# Write To Me At:
@@ -623,8 +623,6 @@ class PersistenceManager(object):
:param `children`: list of children of the input `window`, on first call it is equal to ``None``.
"""
self._hasRestored = False
if children is None:
if HasCtrlHandler(window):
# Control has persist support