start page | rating of books | rating of authors | reviews | copyrights

Book HomeMastering Perl/TkSearch this book

7.2. Listbox Options

As with any of the widgets, you can configure the Listbox using options. The standard widget options are -cursor, -font, -height, -highlightbackground,-highlightcolor, -highlightthickness, -takefocus, -width, -xscrollcommand, and -yscrollcommand. The options specific to Listbox widgets will be further discussed later in this chapter.

-background => color
Sets the color of the area behind the text.

-borderwidth => amount
Sets the width of the edges of the widget. Default is 2.

-cursor => cursorname
Sets the cursor to display when the mouse is over the Listbox.

-exportselection => 0 | 1
Determines if the current Listbox selection is made available for the X selection as well. If set to 1, prevents two Listboxes from having selections at the same time.

-font => fontname
Sets the font of any text displayed within the Listbox.

-foreground => color
Sets the color of nonselected text displayed in the Listbox.

-height => amount
Sets the height of the Listbox.

-highlightbackground => color
Sets the color the highlight rectangle should be when the Listbox does not have the keyboard focus.

-highlightcolor => color
Sets the color the highlight rectangle should be when the Listbox does have the keyboard focus.

-highlightthickness => amount
Sets the thickness of the highlight rectangle. Default is 2.

-relief => 'flat'|'groove'|'raised'|'ridge'|'sunken'|'solid'
Sets the relief of the edges of the Listbox.

-selectbackground => color
Sets the color behind any selected text.

-selectborderwidth => amount
Sets the width of the border around any selected text.

-selectforeground => color
Sets the color of the text in any selected items.

-selectmode => "single" | "browse" | "multiple" | "extended"
Affects how many items can be selected at once; also affects some key/mouse bindings for the Listbox (such as Shift-select).

-setgrid => 0 | 1
Turns gridding off or on for the Listbox. Default is 0.

-takefocus => 0 | 1 | undef
Determines whether the widget can have keyboard focus. 0 means never, 1 means always, undef means dynamic decision.

-width => amount
Sets the width of the Listbox in characters. If amount is 0 or less, the Listbox is made as wide as the longest item.

-xscrollcommand => callback
Assigns a horizontal Scrollbar to widget. See Chapter 6, "The Scrollbar Widget".

-yscrollcommand => callback
Assigns a vertical Scrollbar to widget. See Chapter 6, "The Scrollbar Widget".



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.