Re: Subwidgets
Rob Seegel <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Slaven Rezic wrote:
>ConfigSpecs has already Subwidget support. You can write something
>like
>
> $w->ConfigSpecs(
> -background => [ {-background => 'subwidget1',
> -foreground => 'subwidget2' },
> undef, undef, 'blue'
> ],
> );
>
>to use the -background option to configure subwidget1's background and
>subwidget2's foreground, both by default blue.
>
>
I think I must not have explained very well.
I know about ConfigSpecs and have used it quite a bit in the past, but
are you suggesting using it outside of say a Populate method? I tend to
reserve it for use in setting up Composites, exclusively as the designer
of the composite. It lays out basic rules. Not something I'd use as a
user of that Composite. ConfigSpecs, by itself, is a fairly passive
mechanism that doesn't apply configurations to a widget. It stores the
"option rules" for other methods to use to do the configuring.
What I'm getting at is a shortcut for having to do the following:
$cw->Subwidget('Listbox')->configure( -fg => 'blue', -bg => 'white');
$cw->Subwidget('Button')->configure( -fg => 'blue', -bg => 'yellow');
I'd rather be able to have a simple method do this:
$cw->configureSubwidgets(
[qw/Listbox Button/] => { -fg => 'blue' },
Listbox => { -bg => 'white' },
Button => { -bg => 'yellow'}
);
I see this as coexisting with ConfigSpecs -- not replacing it, and
giving users of Composites a single method to configure a composites
Subwidgets to their liking. One benefit of this, is that I can define a
Hash that has these options and pass it with one method to each of my
composites if I'm using more than one.
Could I instead use ConfigSpecs to setup a new option that applies
foreground to both "Listbox" and "Button" subwidgets ? Sure, but given
even a moderate number of Subwidgets, this approach could easily be
taken to extremes. I could conceivable end up with such options as:
-listbackground
-listforeground
-listheight
-listwidth
-listrelief
-listborderwidth
-buttonbackground
....
and many many more besides. I think this also serves to make the
Composite less accessible to others, if they have to learn dozens
(perhaps even more than a hundred depending on the number of
subwidgets!). Used in moderation, I think this can be a good approach to
use for a select number of often used combinations. Otherwise, it seems
burdensome to me.
Regards,
Rob
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]