7.5. Listbox Style

The default -relief of a listbox is 'sunken'. The default -borderwidth is 2. Figure 7.2 shows the five different relief types (flat, raised, ridge, groove, and sunken). In the first window, the default -borderwidth is used; in the second window, a -borderwidth of 4 is used. To save space in the windows, I didn't draw any scrollbars.

Figure 7.2. Examples of -relief and -borderwidth in listboxes

7.5.1. Style of Selected Items

There is also a borderwidth associated with any selected text. This is controlled by the -selectborderwidth option. Figure 7.3 shows what changing the selection borderwidth to 4 does to the listbox.

Figure 7.3. Example of -selectborderwidth => 4

Sidebar 1. Listbox Indexes

The items in an entry widget are ordered. The first listbox item is at index 0, and the numbers increment by 1. These values are valid for any of the methods that require an index value.

n

An integer index. The first item in a listbox is at index 0.

"active"

The index within the listbox that has the location cursor. If the listbox has the keyboard focus, it will be displayed with an underline.

"anchor"

This index is set with the selectionAnchor(...) method.

"end"

The end of the listbox. Depending on which method is using this index, it could mean just after the last element ...

Get Learning Perl/Tk 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.