Tk

 view release on metacpan or  search on metacpan

pod/options.pod  view on Meta::CPAN


S<    >I<$value> = I<$widget>-E<gt>B<cget>('I<-option>');

S<    >I<$widget>-E<gt>B<configure>(I<-option>=E<gt>I<value> ?,I<-option>=E<gt>I<value> ...?);

S<    >I<@list> = I<$widget>-E<gt>B<configure>('I<-option>');

S<    >I<@lol> = I<$widget>-E<gt>B<configure>;

=head1 DESCRIPTION

All widgets, and images have a standard mechanism for setting and querying
attibutes or options. The mechanism is based on two methods B<configure>
and B<cget>. The behaviour of these methods is as follows:

=over 4

=item I<$widget>-E<gt>B<configure>(I<-option>=E<gt>I<value> ?,I<-option>=E<gt>I<value> ...?);

Sets the values of I<-option> to I<value> for each I<-option>=E<gt>I<value>
pair. The internal B<new> method does an implicit B<configure> in this
form with options passed in at widget create time.

=item I<$widget>-E<gt>B<configure>('I<-option>')

In array context returns a list of five or two elements.  If I<-option>
is an alias for another options it return a list consisting of the
alias option and the name for the option is is an alias for, e.g.,
C<('-bg', 'background')>.  If I<-option> is not an alias the returned
list has the following five elements:

=over 8

=item I<Option Name>

The value of I<-option>, e.g., B<-background>.

=item I<Name>

The option's name in the option database, e.g., C<background>.

=item I<Class>

The option's class value in the option database, e.g., C<Background>.

=item I<Default>

The default value for the option if not specified or in the option database,
e.g., C<grey>.

=item I<Value>

The current value (as returned by B<cget>), e.g., C<white>.

=back

=item I<$widget>-E<gt>B<configure>

Returns a list of lists for all the options supported by I<$widget>.
Each sub-list is in the form returned by B<configure>('I<-option>').
(This mechanism is used by the B<Tk::Derived> class to determine
the options available from base class.)

=item I<$widget>-E<gt>B<cget>('I<-option>')

Returns the current value of I<-option> for I<$widget>.

B<cget>('I<-option>') is clumsy with the need for B<''> due to perl's
parsing rules. Something more subtle using L<tie|perlfunc/tie> might look better.

=back

The following paragraphs describe the common configuration options supported by
widgets in the Tk toolkit.  Every widget does not necessarily support every option
(see the the documentation entries for individual widgets for a list of the
standard options supported by that widget), but if a widget does support an option
with one of the names listed below, then the option has exactly the effect
described below.

In the descriptions below, ``Name'' refers to the option's name in the option
database.  ``Class'' refers to the option's class value
in the option database.  ``Switch'' refers to the switch used in widget-creation
and B<configure> widget methods to set this value. For example, if an option's
configure option is B<-foreground> and there exists a widget I<$widget>, then the
call:

S<    >I<$widget>-E<gt>B<configure>(B<-foreground>=E<gt>B<'black'>)

may be used to specify the value B<black> for the option in the widget I<$widget>.
Configure options may be abbreviated, as long as the abbreviation is unambiguous
(abbreviation is deprecated in perl/Tk).

=head2 Creation options: Widget Name and Class

The B<Name> and B<-class> options can only be specified when a widget is
created, and cannot be changed with B<configure>.  These options determine
the widget's identity and how Tk applies resource values from the
option database (see L<Tk::option>) and so they
cannot be assigned by the options database.

=over 4

=item Name:	I<name>

=item Switch:	B<Name>

Specifies the path element for the widget.  Names generally begin with a
lowercase letter.

Each widget has a unique I<pathname> that follows the hierarchy from the
B<MainWindow> to the widget itself.  Since the widget's B<PathName> is
used to assign options from the options database, it is important to
specify a distinctive B<Name> for any widget that will have non-default
options.  See L<Tk::option> for details.

=item Name:	I<class>

=item Switch:	B<-class>

Specifies a class for the window.  Classes generally begin with an
uppercase letter.



( run in 0.454 second using v1.01-cache-2.11-cpan-5511b514fd6 )