Common Widget Configuration Options

In the remainder of this chapter, we’ll be discussing each widget: the command used to create each widget, the options used to configure them, and the methods for manipulating them.

You’ll find that there are many, many configuration options that are shared by multiple widgets. We could list them individually for each widget, but in the interest of saving a tree or two, we’re instead going to list the shared options up front, rather than repeating them over and over. That way we can concentrate on the options that are crucial to the behavior of each particular widget, and save the reader from being lost in a sea of options.

The following options are supported by the widgets noted:

-activebackground => color

Sets the background color when the mouse cursor is over the widget.

Applicable widgets: Button, Checkbutton, Menu, Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar

-activeforeground => color

Sets the text color when the mouse cursor is over the widget. Applicable widgets: Button, Checkbutton, Menu, Menubutton, Optionmenu, Radiobutton

-anchor => position

Causes the text to stick to that position in the widget. Values for position are 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', and 'center'. Applicable widgets: Button, Checkbutton, Label, Menubutton, Optionmenu, Radiobutton

-background => color
-bg => color

Sets the background of the widget to the specified color. Applicable widgets: Button, Canvas, Checkbutton, Entry, Frame, Label, ...

Get Perl in a Nutshell 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.