pythonware.com products ::: library ::: search ::: daily Python-URL!
   

Options

Back   Next   

 Options

The Radiobutton widget supports the following options:

Table 38-1. Radiobutton Options

Option

Type

Description

activebackground, activeforeground

color

The color to use when the button is activated.

anchor

constant

Controls where in the button the text (or image) should be located. Use one of N, NE, E, SE, S, SW, W, NW, or CENTER. Default is CENTER. If you change this, it is probably a good idea to add some padding as well, using the padx and/or pady options.

background (bg), foreground (fg)

color

The button color. The default is platform specific.

bitmap

bitmap

The bitmap to display in the widget. If the image option is given, this option is ignored.

The following bitmaps are available on all platforms: "error", "gray75", "gray50", "gray25", "gray12", "hourglass", "info", "questhead", "question", and "warning".

The following additional bitmaps are available on the Macintosh only: "document", "stationery", "edition", "application", "accessory", "folder", "pfolder", "trash", "floppy", "ramdisk", "cdrom", "preferences", "querydoc", "stop", "note", and "caution".

You can also load the bitmap from an XBM file. Just prefix the filename with an at-sign, for example "@sample.xbm".

borderwidth (bd)

int

The width of the button border. The default is platform specific, but is usually 1 or 2 pixels.

command

callback

A function or method that is called when the button is pressed. The callback can be a function, bound method, or any other callable Python object.

cursor

cursor

The cursor to show when the mouse is moved over the button.

default

int

If set, the button is a default button. Tk will indicate this by drawing a platform specific indicator (usually an extra border). NOTE: The syntax has changed in 8.0b2!!!

disabledforeground

color

The color to use when the button is disabled. The background is shown in the background color.

font

font

The font to use in the button. The button can only contain text in a single font.

highlightbackground, highlightcolor

color

Controls how to draw the focus highlight border. When the widget has focus, the border is drawn in the highlightcolor color. Otherwise, it is drawn in the highlightbackground color. The defaults are system specific.

highlightthickness

distance

Controls the width of the focus highlight border. Default is typically one or two pixels.

image

image

The image to display in the widget. If specified, this takes precedence over the text and bitmap options.

indicatoron

bool

Controls if the indicator should be drawn or not. For check and radio buttons, this is on by default. Setting this option to false means that the relief will be used as the indicator. If the button is selected, it is drawn as SUNKEN instead of RAISED. For a menu button, this is off by default. Setting it to true draws a small indicator to the right. This is used by the OptionMenu widget.

justify

constant

Defines how to align multiple lines of text. Use LEFT, RIGHT, or CENTER.

padx, paxy

distance

Button padding. These options specify the horizontal and vertical padding between the text or image, and the button border.

relief

constant

Border decoration. Usually, the button is SUNKEN when pressed, and RAISED otherwise. Other possible values are GROOVE, RIDGE, and FLAT.

selectcolor

color

Color to use for the selector.

selectimage

image

Graphic image to use for the selector.

state

constant

The button state: NORMAL, ACTIVE or DISABLED. Default is NORMAL.

takefocus

flag

Indicates that the user can use the Tab key to move to this button. Default is an empty string, which means that the button accepts focus only if it has any keyboard bindings (default is on, in other words).

text

string

The text to display in the button. The text can contain newlines. If the bitmap or image options are used, this option is ignored.

textvariable

variable

Associates a Tkinter variable (usually a StringVar) to the button. If the variable is changed, the button text is updated.

underline

int

Default is -1.

value

None

The value to assign to the associated variable when the button is pressed.

variable

variable

Associates a Tkinter variable to the button. When the button is pressed, the variable is set to value. Explicit changes to the variable are automatically reflected by the buttons.

width, height

distance

The size of the button. If the button displays text, the size is given in text units. If the button displays an image, the size is given in pixels (or screen units). If the size is omitted, it is calculated based on the button contents.

wraplength

distance

Determines when a button's text should be wrapped into multiple lines. This is given in screen units. Default is no wrapping.

Back   Next