Tk::CWidget - Frame-based Composite Base class. |
Tk::CWidget - Frame-based Composite Base class.
CWidget is a base class for Frame-based Composite widgets. It contains methods that may be useful for Composites, and is used as a way of extending or overriding the Widget, Derived, or Frame modules without directly changing them. It is not intended for use as a standalone widget. Currently, it has few methods, but will likely increase as common code is moved from subclasses to this one.
The first example shows that for each named subwidget, one or more options can be set.
$cwidget->configure(-subwidgets => [ LabelA => { -background => 'blue', -foreground => 'white' }, LabelB => { -background => 'white', -foreground => 'blue' } ]);
The second example show that more than one subwidget can be associated with a set of options.
$cwidget->configure(-subwidgets => [ ['LabelA', 'LabelB'] => { -bg => 'blue', -fg => 'white'}, LabelA => { -text => 'A'}, LabelB => { -text => 'B'} ]);
Why is this useful? If you have several composites that have the same option configurations, this allows the options to be defined once in a variable, and then passed to each one, eliminating some of the common code from repeatedly calling:
$cwidget->Subwidget('LabelA')->configure(...)
$cwidget->configureSubwidgets( ['LabelA', 'LabelB'] => { -bg => 'blue', -fg => 'white'}, LabelA => { -text => 'A'}, LabelB => { -text => 'B'} );
or:
$cwidget->configureSubwidgets([ ['LabelA', 'LabelB'] => { -bg => 'blue', -fg => 'white'}, LabelA => { -text => 'A'}, LabelB => { -text => 'B'} ]);
Rob Seegel (RobSeegel@comcast.net)
Tk::CWidget - Frame-based Composite Base class. |