Hi Marcus,
Validators are similar to, but not the same as, Perl/Tk. As you say, in
Perl/Tk, changes to the underlying variable immediately appear in the Tk
widget - a great feature but also a source of problems, as you have found.
However, I think that Wx validators only transfer the data to the control
when $window->TransferDataToWindow is called, and back again when
$window->TransferDataFromWindow is called. (I'll check this out with some
trials).
For wxDialogs, these are both called automatically as part of Dialog
initialisation and dismissal (TransferDataFromWindow is only called when the
modal result is wxID_OK, I think).
Hence, using wxValidators we have an inbuilt mechanism whereby our variables
are only updated when the user OK's the window (and validation is
implemented, too!).
I ended up having to wrap my Tk widgets and windows in my own objects to
achieve this sort of functionality for a large (200 screens plus) system
I've been developing/supporting. If only I'd known about wxWindows at the
time... It's so much more consistent in its approach than Tk...
One feature I'm thinking of implementing is the ability to supply a callback
for the TransferToWindow and TransferFromWindow wxValidator methods, so that
we can supply data from object methods and pump data back into object
methods, rather than having to rely on variable addresses. (Most of my Perl
code is OO, and so I want to be able to use property accessors, rather than
property addresses).
Enough jabbering from me....
James
----- Original Message -----
From: "Marcus" <lists@...>
To: <wxperl-users@...>
Sent: 05 July 2002 13:11
Subject: [wxperl-users] Validators
> I think the vaildators are a good idea. If I understand the concept
> correctly, then this is how Perl/Tk works, only you have no choice.
>
> The downside is that when you "bind" a variable to a control, then any
> changes while you are working with the variable appear immediately in
> the GUI. An example that caused me and my beta tester many many hours
> of grief is the following. I had to escape backslashes when storing
> paths in a config file, in the GUI they were unescaped. As you can
> imagine unescaped backslashes can cause amazing problems when let
> loose. The only workaround was to keep copying variables back and
> forth, and making lots of temp variables.
>
> Only a word of warning, which should be at the top of the docs, in form
> of a "When to use..". Otherwise, I am in favour of the validators,
> since they can be very useful.
>
> Marcus
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Bringing you mounds of caffeinated joy.
> http://thinkgeek.com/sf
> _______________________________________________
> wxperl-users mailing list
> wxperl-users@...
> https://lists.sourceforge.net/lists/listinfo/wxperl-users
|