Hello,
I would like to be able to save a ‘customtreectrl’ state (ie items folded or not, checked or not…) when the user closes an application, in order to bring in back at the next launch. I tried to use the ‘persist’ module for this, but I encounter a problem when running the sample.py program (see attached file).
When using wxPython 2.8.12.1, I get the following error:
" self._persistMgr.Save(self._wxCustomTree)
File “C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\persist\persistencemanager.py”, line 468, in Save
self._persistentObjects[name].Save()
File “C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\persist\persistencemanager.py”, line 127, in Save
self._persistentHandler.Save()
File “C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\persist\persist_handlers.py”, line 924, in Save
scrollPos = scroll.GetScrollPos()
File “C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx_core.py”, line 10328, in GetScrollPos
return core.Window_GetScrollPos(*args, **kwargs)
TypeError: Required argument ‘orientation’ (pos 2) not found"
I read somewhere that this might be related to wxPython version, so I downloaded and installed the latest available, version ‘2.9.4.0’.
When running the sample, I do not get the ‘TypeError’ as above, but the tree state is not saved, nothing is remembered across successive application close/launch.
After digging a while in the ‘persist’ module code, I then tried to comment line #2509 in file persist_handlers.py (from wx ‘2.9.4.0’):
#(“AUIHandler”, (wx.Panel, )),
And now this works great! The tree state (item selection for example) is correctly saved.
It seem that the ‘persist’ module fails to correctly identify the ‘customtreectrl’ object, and thinks it is a simple wx.Panel instead…
Thanks for your help!
Jérôme
sample.py (3.5 KB)