agw.persist - for aui layout but not caption

28 views
Skip to first unread message

Werner

unread,
Apr 19, 2012, 9:42:00 AM4/19/12
to wxpytho...@googlegroups.com
I like to persist the AUI layout but things like the caption should not
be persisted as they are user language dependend and also don't want to
have to throw away a layout persist file if I change the caption of
something.

Do we need a new style for this?

Currently I use:
PM.PM_SAVE_RESTORE_AUI_PERSPECTIVES

maybe have something like:
PM.PM_SAVE_RESTORE_AUI_LAYOUTONLY_PERSPECTIVES

or
PM.PM_SAVE_RESTORE_AUI_NOCAPTION_PERSPECTIVES

Werner

Andrea Gavana

unread,
Apr 22, 2012, 6:19:59 AM4/22/12
to wxpytho...@googlegroups.com
Hi Werner,

This is a good idea but a bit complicated to implement: the pane
captions are restored inside the AUI code, and specifically when you
call LoadPerspective to load an existing perspective. It has been
argued in the past (although I can't find the thread right now) that
AUI shouldn't save and restore pane captions as they are
language/translation dependent. But nothing has been done to change
this behaviour, as far as I remember.

There is also a ticket for wxAUI about this:

http://trac.wxwidgets.org/ticket/12528

The only possibility I see at the moment is a convoluted approach in
which the pane captions are always stored in their original (default)
language in the perspective; then, when restoring the perspective, the
appropriate translation is applied for the pane caption. The whole
process requires keeping some kind of dictionary with Name -> Caption
and use that to flip through saving/loading translated captions. It's
a fair bit of work overall and I am not exactly sure I can get it
right...

Andrea.

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

Werner

unread,
Apr 22, 2012, 6:46:27 AM4/22/12
to wxpytho...@googlegroups.com
Hi Andrea,
It is both I18N/gettext issue and also if you change the caption in the
source code, neither will show up as persist restore brings back the old
one.

What about if persist restore gets the 'current' caption just before
doing the actual restore and then reset it after the restore?

Werner

Andrea Gavana

unread,
Apr 23, 2012, 7:49:55 AM4/23/12
to wxpytho...@googlegroups.com
Hi Werner,

That's a possibility as well, and I believe it will be easier to
implement than my original idea. I don't have a lot of time at the
moment but I'll see what I can do in the near future. Of course, if
you would like to give it a try and implement it yourself, I'll be
more than happy to apply patches (hint hint :-D ).

Werner

unread,
Apr 23, 2012, 7:51:53 AM4/23/12
to wxpytho...@googlegroups.com
Hi Andrea,

On 23/04/2012 13:49, Andrea Gavana wrote:
...


> That's a possibility as well, and I believe it will be easier to
> implement than my original idea. I don't have a lot of time at the
> moment but I'll see what I can do in the near future. Of course, if
> you would like to give it a try and implement it yourself, I'll be
> more than happy to apply patches (hint hint :-D ).

Hint hint has arrived:-) .

Will give it a try over the next few days.

Werner

Werner

unread,
Apr 25, 2012, 3:16:50 AM4/25/12
to wxpytho...@googlegroups.com
Hi Andrea,

On 23/04/2012 13:49, Andrea Gavana wrote:

....


> That's a possibility as well, and I believe it will be easier to
> implement than my original idea. I don't have a lot of time at the
> moment but I'll see what I can do in the near future. Of course, if
> you would like to give it a try and implement it yourself, I'll be
> more than happy to apply patches (hint hint :-D ).

Started to have a look at this and first just wanted to see if the
replace tactic would work, so no flag yet.

In the attached patch I save the caption loaded from code and then later
on restore it. Checking it through the debugger I can see that the
correct thing gets restored - BUT on screen I see the data from the
persist restore.

I searched but just don't see where else the caption is being reset
during the persist restore process.

If you have a tip on where else I should look, please let me know.

Will have another look at it this afternoon.

Werner

frameAUI.patch

Werner

unread,
Apr 25, 2012, 6:41:37 AM4/25/12
to wxpytho...@googlegroups.com
I think I got it, mixed up "p" and "pane" when doing the restore.

Now I need to figure out how/where to create the flag and how to pass it
around.

- I think the flag should be in persist and it passes it to
"framemanager.LoadPerspective". Are you o.k. with that approach?

Werner

Andrea Gavana

unread,
Apr 25, 2012, 7:28:45 AM4/25/12
to wxpytho...@googlegroups.com
Hi Werner,
I think that would be OK, thank you for your contribution.

Werner

unread,
Apr 25, 2012, 8:38:41 AM4/25/12
to wxpytho...@googlegroups.com
Hi Andrea,

On 25/04/2012 13:28, Andrea Gavana wrote:
...


> I think I got it, mixed up "p" and "pane" when doing the restore.
>
> Now I need to figure out how/where to create the flag and how to pass it
> around.
>
> - I think the flag should be in persist and it passes it to
> "framemanager.LoadPerspective". Are you o.k. with that approach?

Attached a proposed patch. Please review carefully the stuff in
persist_handler as I don't really know what I am
doing with extracting/calculating on flags, i.e. would it work when one
uses/adds other flags.


> I think that would be OK, thank you for your contribution.

It is nothing compared to all the stuff you do for wxPython, so thanks
to you;-) .

Werner

restorecodecaption.patch

Andrea Gavana

unread,
Apr 25, 2012, 1:04:00 PM4/25/12
to wxpytho...@googlegroups.com
Hi Werner,

On 25 April 2012 14:38, Werner wrote:
> Hi Andrea,
>
> On 25/04/2012 13:28, Andrea Gavana wrote:
> ...
>
>> I think I got it, mixed up "p" and "pane" when doing the restore.
>>
>> Now I need to figure out how/where to create the flag and how to pass it
>> around.
>>
>> - I think the flag should be in persist and it passes it to
>> "framemanager.LoadPerspective".  Are you o.k. with that approach?
>
> Attached a proposed patch.  Please review carefully the stuff in
> persist_handler as I don't really know what I am
> doing with extracting/calculating on flags, i.e. would it work when one
> uses/adds other flags.

I don't see anything wrong with the patch, I believe it will work OK.
I have applied it to the latest SVN (plus another small nice addition
to the AuiManager's list of features).
Reply all
Reply to author
Forward
0 new messages