10.1. Creating a Scale

As with other widgets, you can create a scale by using a parent widget and passing options to the scale to change its configuration:

$parent->Scale( [ option => value ] )->pack;

Use one of the geometry managers discussed in Chapter 2, to place it on the screen (such as pack, as shown in the preceding code).

Most of the options associated with the scale widget are the standard options that used with all other widgets. All of the possible options are in the following list. A discussion of special options that have a slightly different meaning for the scale and options that are specific to the scale widget follows the list.

-activebackground => color

Sets the color the slider's background should be when the cursor is over the slider (the -state is 'active').

-background =>color

Sets the color the slider's background should be when the cursor is not over the slider (-state is 'normal').

-bigincrement => amount

Sets the amount by which the slider will change value when required to do so in large increments. Default is 0, causing the value to change by 1/10 the top value of the scale.

-borderwidth => amount

Sets the width of the edges of the widget. Default is 2.

-command => callback

Sets the callback invoked when the slider is moved.

-cursor => cursorname

Determines the cursor to display when the mouse is over the scale.

-digits => amount

Indicates how many significant digits to retain when conversion from a number to a string takes place.

-font => fontname ...

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.