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

Hiding the Indicator

One way a Checkbutton or Radiobutton differs from a standard Button is the indicator. Use the -indicatoron option to tell Perl/Tk not to draw that funny little square Button at all:

-indicatoron => 0 | 1

As we have seen in previous examples, the default for -indicatoron is 1 (i.e., show the indicator). If we change this -indicatoron to 0, the Checkbutton will look almost like a normal Button (without quite as much space around the text, however). Though it looks a lot like a regular Button, its behavior when clicked (to turn the hidden indicator on) is completely different (see Figure 4-36). Note that the -relief option is ignored completely when -indicatoron is set to 0.

Unchecked (left) and checked (right) Checkbutton with -indicatoron => 0

Figure 4-36. Unchecked (left) and checked (right) Checkbutton with -indicatoron => 0

In this example, the color for the background on the checked Button is the -selectcolor, not the -backgroundcolor. You might want to use the nonindicator configuration if you change the text of the Button to reflect the new state of the Checkbutton (for instance, changing Logging Enabled to Logging Disabled).

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