Phoenix and wx.lib.agw.persist

28 views
Skip to first unread message

Ray S

unread,
Apr 16, 2015, 6:31:42 PM4/16/15
to wxpytho...@googlegroups.com
The code below works fine in wx 2.8*, but fails to do anything with with 3*
I don't see what the difference is in the 3* docs...
Is there a new, or better, idiom?

BTW, "Upload" feature failed on Google...


def save_state(self, path=None):
    if path is not None:
        self._persistMgr.SetPersistenceFile(path)
    for obj in [self, self.panelEKGPlot.Tools]:
        self._persistMgr.SaveAndUnregister(obj)
        for key in dir(obj):
            try:
                val = getattr(obj, key)
            except AttributeError:
                continue
            try:
                self._persistMgr.SaveAndUnregister(val)
            except (TypeError, AttributeError):
                pass
            except:
                print('save err:', key, sys.exc_info())
    for obj in self.panelEKGPlot.checkBoxList:
        for key in dir(obj):
            try:
                val = getattr(obj, key)
            except AttributeError:
                continue
            try:
                self._persistMgr.SaveAndUnregister(val)
            except (TypeError, Exception, AttributeError):
                pass
            except:
                print('save err:', key, sys.exc_info())
    #self._persistMgr.SaveAndUnregister(self.checkBoxRemoveOffsets)
    #self._persistMgr.RegisterAndRestore(self.choiceMRUDs)
    try:
        self._persistMgr.RegisterAndRestore(self.choiceMRUDs)
    except (TypeError, Exception, AttributeError):
        pass
    except:
        print('restore err:', key, sys.exc_info())
       
       

Werner

unread,
Apr 17, 2015, 2:19:17 AM4/17/15
to wxpytho...@googlegroups.com
Hi Ray,

On 4/17/2015 0:31, Ray S wrote:
> The code below works fine in wx 2.8*, but fails to do anything with
> with 3*
> I don't see what the difference is in the 3* docs...
> Is there a new, or better, idiom?
>
> BTW, "Upload" feature failed on Google...
I do see the code in your first post, but it is kind of 'dimmed'.

I just do:

self.persistMgr.RegisterAndRestoreAll(self.view)
if self.persistMgr.HasRestored():
self.viewLayout(self.view)
else:
self.doLayout()

and on close:
self.persistMgr.SaveAndUnregister()

This works for me in 2.9.5 and in Phoenix, haven't tried in 3.0 classic.

Why are you doing it for each object, persist if no window is given does
it for all registered windows.

Could you do a http://wiki.wxpython.org/MakingSampleApps and I'll try
with classic.

Werner

Ray S

unread,
Apr 17, 2015, 12:27:31 PM4/17/15
to wxpytho...@googlegroups.com
Thanks Werner,
 
I'll try your snip, I forget why I did it that way, it was first time with the module and I mangled some example code.
The main code is Boa-generated, but I have 2 sets of on-the-fly generated checkboxes that were trouble if I recall.
I'll see if I can jin a short sample in Boa as well...
Reply all
Reply to author
Forward
0 new messages