## 5.8 Scales

A scale widget allows to select a number from a certain range by moving a slider. Each time the slider is moved, an action attached to the slider is invoked with a single argument giving the current number value of the slider.

In Figure 5.9 an example is shown which allows to display a color determined by three sliders for the intensity of the base colors red, green, and blue. The object `F` stores the intensity for each base color in an attribute. Whenever the method `bg` is executed it changes the intensity for one of the base colors and changes the background color to the combination of all three base colors.

  `L ={New class $ from Tk.listener
  attr red:0 green:0 blue:0
  meth bg(C I)
  C := I {F tk(configure bg:c(@red @green @blue))}
  end
  end tkInit}
  F ={New Tk.frame tkInit(parent:W height:2#c)}
  Ss={Map [red green blue]
  fun {$ C}
  {New Tk.scale tkInit(parent:W orient:horizontal length:8#c
  label:C 'from':0 to:255
  action: L # bg(C)
  args: [int])}
  end}
  {Tk.send pack(b(Ss) F fill:x)}`

Figure 5.9: Scales to configure a frame's background color.

The sliders are configured with the `label` option to display the name of the base color as their labels. The other options besides of `action` and `args` are self explanatory, more information on them can be found in `scale`.

The value for the `args` option must be a type specification similar to that used for the specification of argument types in event bindings (see Section 5.5.2. The only difference is that no event argument specification is required. Invoking the action is also similar. For instance, if the scale for the color `red` changes its value to `10`, the message `bg(red 10)` will eventually be served by the listener `L`.