Skip to Main Content
Learning Perl/Tk
book

Learning Perl/Tk

by Nancy Walsh
January 1999
Beginner content levelBeginner
373 pages
9h 43m
English
O'Reilly Media, Inc.
Content preview from Learning Perl/Tk

A.1. The configure Method

The basic format of the configure method is as follows:

$widget->configure( [ option => newvalue, ... ] );

Depending on the arguments passed to it, the configure method can do three things:

  • Set or change the values of the options for $widget

  • Get the current value of any option for $widget

  • Get the current values for all of the options for $widget

To set or change the value for an option, send the option pair exactly as it would have appeared in the widget creation command:

$widget->configure(-option => newvalue);

Whatever effect the option has will take place immediately. To see the current values for a single option, send the option you are interested in as the argument. The return value depends on whether configure is called in list context or scalar context. In the following line, configure is called in list context (since its return value is being assigned to an array):

@info = $widget->configure(-highlightthickness);

In list context, an array of scalars is returned. The results of this call look like this:

-highlightthickness highlightThickness HighlightThickness 2 2

The following five values are in the returned array:

0 Option name
1 Option name from the option database (also as it would appear in the .Xdefaults file)
2 Class in the option database
3 Default value of the option
4 Current value of the option

Often, all you're interested in is the current value of the option. If that's the case, call configure in scalar context by assigning the result ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl/Tk

Mastering Perl/Tk

Stephen Lidie, Nancy Walsh

Publisher Resources

ISBN: 1565923146Supplemental ContentCatalog PageErrata