Persist with a Dialog and AUI

Hi,

I have a SizedDialog in it I have an aui Manager, but I can't get it to persist the layout of the panels controlled by the aui manager using wx.lib.agw.persist.

I use the same method which works for splitters, auinotebook etc.

Do I need to set something special when an aui Manager is involved on a Dialog?

Werner

Hi Werner,

Hi,

I have a SizedDialog in it I have an aui Manager, but I can't get it to
persist the layout of the panels controlled by the aui manager using
wx.lib.agw.persist.

I use the same method which works for splitters, auinotebook etc.

Do I need to set something special when an aui Manager is involved on a
Dialog?

Does the AUIHandler class return anything when you call its `Restore`
method? i.e., there is a line in the AuiHandler class:

perspective = self._pObject.RestoreValue(name)

Does `perspective` evaluate to a string or to ``None``?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 April 2012 20:46, Werner wrote:

That break point isn't hit, so I put one to the save one and that one isn't hit either, but I do hit save/restore for scrolled windows which are the panels controlled by the aui manager.

My dialog is something along these lines.

sc.SizedDialog
-- content pane to which I assign a name
-- aui manager is managing the content pane
--- panels managed by aui are sized_panel or sized_scrolled_panel all have a name assigned

On Close I do:
self._persistMgr.SaveAndUnregister()

and on open I do:
self._persistMgr.RegisterAndRestoreAll(self.view)

self.view would be the dialog in the above.

Werner

···

On 10/04/2012 20:57, Andrea Gavana wrote:

Hi Werner,

On 10 April 2012 20:46, Werner wrote:

Hi,

I have a SizedDialog in it I have an aui Manager, but I can't get it to
persist the layout of the panels controlled by the aui manager using
wx.lib.agw.persist.

I use the same method which works for splitters, auinotebook etc.

Do I need to set something special when an aui Manager is involved on a
Dialog?

Does the AUIHandler class return anything when you call its `Restore`
method? i.e., there is a line in the AuiHandler class:

perspective = self._pObject.RestoreValue(name)

Does `perspective` evaluate to a string or to ``None``?

If I understand correctly, that's probably because AUIHandler is
instantiated only with TLWHandler, and your dialog content pane is not
a top level window. One possible solution would be to add this line:

("AUIHandler", (wx.Window, )),

*At the end* of the HANDLERS constant in the persist_handlers.py file.
It might work, but again I will need a sample app to play with in
order to check if it works or not (or you could do it for me...).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 April 2012 21:48, Werner wrote:

On 10/04/2012 20:57, Andrea Gavana wrote:

Hi Werner,

On 10 April 2012 20:46, Werner wrote:

Hi,

I have a SizedDialog in it I have an aui Manager, but I can't get it to
persist the layout of the panels controlled by the aui manager using
wx.lib.agw.persist.

I use the same method which works for splitters, auinotebook etc.

Do I need to set something special when an aui Manager is involved on a
Dialog?

Does the AUIHandler class return anything when you call its `Restore`
method? i.e., there is a line in the AuiHandler class:

perspective = self._pObject.RestoreValue(name)

Does `perspective` evaluate to a string or to ``None``?

That break point isn't hit, so I put one to the save one and that one isn't
hit either, but I do hit save/restore for scrolled windows which are the
panels controlled by the aui manager.

My dialog is something along these lines.

sc.SizedDialog
-- content pane to which I assign a name
-- aui manager is managing the content pane
--- panels managed by aui are sized_panel or sized_scrolled_panel all have a
name assigned

On Close I do:
self._persistMgr.SaveAndUnregister()

and on open I do:
self._persistMgr.RegisterAndRestoreAll(self.view)

self.view would be the dialog in the above.

I did this instead, to have fewer problems with 'default/bad' window names, i.e. just added "cPanel" to the BAD_DEFAULT_NAMES.

("AUIHandler", (wx.lib.sized_controls.SizedPanel, )),

Now the breakpoint in the AUIHandler.Save method is hit, but as it does:

eventHandler = self._window.GetEventHandler()

We are not quit there.

self._window at this point is my SizedDialog.

sizeDialog
- contentPane
--- aui manages contentPane

In the debugger I would get at the aui manager by doing this instead:
eventHandler = self._window.mainPanel.GetEventHandler()

It is fine to use AUI to manage e.g. a panel, no?

Maybe instead of using GetEventHandler have something like GetAUIManager? Maybe being added to the managed window by SetManagedWindow?

Werner

···

On 10/04/2012 22:00, Andrea Gavana wrote:

("AUIHandler", (wx.Window, )),

("AUIHandler", (wx.Window, )),

I did this instead, to have fewer problems with 'default/bad' window names,
i.e. just added "cPanel" to the BAD_DEFAULT_NAMES.

("AUIHandler", (wx.lib.sized_controls.SizedPanel, )),

Now the breakpoint in the AUIHandler.Save method is hit, but as it does:

eventHandler = self._window.GetEventHandler()

We are not quit there.

self._window at this point is my SizedDialog.

Uhm, how is that possible? If the breakpoint is hit, shouldn't it mean
that self._window is a subclass of wx.lib.sized_controls.SizedPanel?
This is what the line:

("AUIHandler", (wx.lib.sized_controls.SizedPanel, )),

is meant to be. Or am I missing something? (Or do I need some sleep?)

In the debugger I would get at the aui manager by doing this instead:
eventHandler = self._window.mainPanel.GetEventHandler()

It is fine to use AUI to manage e.g. a panel, no?

Yes, it is.

Maybe instead of using GetEventHandler have something like GetAUIManager?
Maybe being added to the managed window by SetManagedWindow?

Well, in theory it should be the same: if a window is managed by AUI,
its EvtHandler is actually AuiManager (because all other event
handlers are pushed back by AuiManager).

I feel I am missing something basic here...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 April 2012 22:45, Werner wrote:

On 10/04/2012 22:00, Andrea Gavana wrote:

Hi Andrea,

···

On 10/04/2012 22:53, Andrea Gavana wrote:

I feel I am missing something basic here...

It is more likely me who is messing/confusion things/you.

It is time to do a little app, will do that tomorrow.

Werner

Hi Andrea,

Hi Andrea,

I feel I am missing something basic here...

It is more likely me who is messing/confusion things/you.

It is time to do a little app, will do that tomorrow.

Attached find the sample application and a suggested patch - similar to the suggestion you made yesterday.

Needed to add 'cPanel' to BadDefaults and create a "kind" entry.

But it is not quit there.

Run it and enlarge it and resize the pane on the left, close and reopen and it that should have worked.

Now minimize one of the panes on the right and close and reopen, that pane is no longer shown, not as a toolbar entry nor ...

Werner

sizedauipersist.py (8.96 KB)

persist.patch (1.51 KB)

···

On 10/04/2012 22:57, Werner wrote:

On 10/04/2012 22:53, Andrea Gavana wrote:

Hi Werner,

Hi Andrea,

Hi Andrea,

I feel I am missing something basic here...

It is more likely me who is messing/confusion things/you.

It is time to do a little app, will do that tomorrow.

Attached find the sample application and a suggested patch - similar to the
suggestion you made yesterday.

Needed to add 'cPanel' to BadDefaults and create a "kind" entry.

But it is not quit there.

Run it and enlarge it and resize the pane on the left, close and reopen and
it that should have worked.

Now minimize one of the panes on the right and close and reopen, that pane
is no longer shown, not as a toolbar entry nor ...

It's a bug in AUI.

I just played a bit with your sample and with the AUI
Save/LoadPerspective methods and it appears that minimized panes do
not get restored in any way, as LoadPerspective doesn't take into
account the fact that a minimized pane has a "_min" string attached to
it.

I have fixed it on my local copy of framemanager.py (and I attach a
diff against the latest SVN). I'll upload the new version when I get
back home tonight.

Thank you, that was a bad and hard one :smiley:

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

framemanager.diff (1.31 KB)

···

On 11 April 2012 10:42, Werner wrote:

On 10/04/2012 22:57, Werner wrote:

On 10/04/2012 22:53, Andrea Gavana wrote:

Hi Andrea,

···

On 11/04/2012 13:52, Andrea Gavana wrote:

It's a bug in AUI.

I just played a bit with your sample and with the AUI
Save/LoadPerspective methods and it appears that minimized panes do
not get restored in any way, as LoadPerspective doesn't take into
account the fact that a minimized pane has a "_min" string attached to
it.

I have fixed it on my local copy of framemanager.py (and I attach a
diff against the latest SVN). I'll upload the new version when I get
back home tonight.

Thank you, that was a bad and hard one :smiley:

Sorry about that.

Werner

Should be fixed in SVN :slight_smile:

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 11 April 2012 15:42, Werner wrote:

Hi Andrea,

On 11/04/2012 13:52, Andrea Gavana wrote:

It's a bug in AUI.

I just played a bit with your sample and with the AUI
Save/LoadPerspective methods and it appears that minimized panes do
not get restored in any way, as LoadPerspective doesn't take into
account the fact that a minimized pane has a "_min" string attached to
it.

I have fixed it on my local copy of framemanager.py (and I attach a
diff against the latest SVN). I'll upload the new version when I get
back home tonight.

Thank you, that was a bad and hard one :smiley:

Sorry about that.

Great, just updated and I can confirm that this works now.

Thanks
Werner

···

On 11/04/2012 21:00, Andrea Gavana wrote:

On 11 April 2012 15:42, Werner wrote:

Hi Andrea,

On 11/04/2012 13:52, Andrea Gavana wrote:

It's a bug in AUI.

I just played a bit with your sample and with the AUI
Save/LoadPerspective methods and it appears that minimized panes do
not get restored in any way, as LoadPerspective doesn't take into
account the fact that a minimized pane has a "_min" string attached to
it.

I have fixed it on my local copy of framemanager.py (and I attach a
diff against the latest SVN). I'll upload the new version when I get
back home tonight.

Thank you, that was a bad and hard one :smiley:

Sorry about that.

Should be fixed in SVN :slight_smile: