O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. The Scale Widget

A Scale widget looks similar to a Scrollbar but doesn’t scroll anything other than itself. What it does is keep track of a number. When you change the position of the button in the Scale, the numeric value associated with the Scale changes. Some things you can do with a Scale widget are:

  • Create a widget from which a user can select a number between 1 and 100.

  • Create three Scales, each representing a value in an RGB (red, green, blue) number.

  • Create four sliders, each representing a portion of an IP address. Each Scale can go from 0 to 255, and it would probably be smart to start them at 255. Use a Label widget to show the completed IP address, periods and all.

  • Create a temperature Scale that starts at -50 and goes to 130 degrees.

  • Show the amount of rainfall so far this year. The Scale can be marked to show every five inches.

The Scale widget can be placed horizontally or vertically, depending on where you have the most room in your application window. Figure 10-1 shows a scale widget.

Scale widget

Figure 10-1. Scale widget

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required