wxpython - How do I use PM_PERSIST_CONTROL_VALUE?
问题描述
I am writing a program in Python and am busy implementing PersistenceManager for my program. One of the main features of the interface is a wx.treectrl for which I would like to save the state.
I have got things to the point that the main frame's size and position are saved/restored and I also have the expansion of tree items implemented. I cannot get my head around how to implement PM_PERSISTENT_CONTROL_VALUE, which seems what I need in order to restore the selected item on the tree.
Here is the code that I have at the end of init of my main frame:
self.SetName('MyApp')
self.document_tree.SetName('DocumentTree')
_configFile = os.path.join(os.path.expanduser("~"), "Documents", "MyApp.pm")
self._persistMgr = pm.PersistenceManager.Get()
self._persistMgr.SetPersistenceFile(_configFile)
self._persistMgr.RegisterAndRestoreAll(self)
self._persistMgr.Save(self)
I have tried a couple of things, but cannot seem to get the "document_tree" control to highlight the value that was highlighted when the program was closed.
Thank you in advance for your suggestions.
Marc.
解决方案
好的,这是我必须添加到我的代码中的内容:
self._persistMgr.SetManagerStyle(pm.PM_DEFAULT_STYLE|pm.PM_SAVE_RESTORE_TREE_LIST_SELECTIONS)
我把上面的直接放在下面
self._persistMgr = pm.PersistenceManager.Get()
...现在它可以工作了。
马克。
推荐阅读
- grails - Cron 表达式被多次调用
- python - pip-req-build 临时文件夹的用途是什么?我可以阻止使用它吗?
- kubernetes - Kubernetes - 流量总是重定向到同一个 pod
- java - 使用非主键列的休眠连接
- sql - 变量具有撇号时的字符串生成器 SELECT 查询
- android - 错误:(1, 0) 插件太旧,请更新到更新版本,或设置 ANDROID_DAILY_OVERRIDE "e71316b1598b09073ff04c4315280c3b0e755860"
- fortran - 在 Fortran 中混合整数类型
- python - 使用上下文管理器临时覆盖语言环境
- php - 需要在 fopen、file_get_contents 和 fread 等 php 函数上设置 Timeout
- python - 在 Python (numpy) 中导入文件作为连续内存数组