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 ...

Get Learning Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.