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

The TList Widget

The TList widget is very similar to a Listbox, because it displays a list of things. The Listbox is limited to displaying lists of text strings. The TList widget can display any item type, and each item can be a different color and/or font. One of the most common questions asked about a Listbox is whether it can display different color items. The answer to that is no, but a TList can. The TList can also handle displaying multiple columns of items.

When you create a TList, you specify options just as you would when creating any other widget. These options are completely standard and behave as expected: -background, -borderwidth, -class, -command, -cursor, -foreground, -font, -height, -highlightcolor, -highlightthickness, -padx, -pady, -relief, -selectbackground, -selectborderwidth, -selectforeground, -selectmode, -state, -xscrollcommand, -yscrollcommand, and -width.

The following options are specific to a TList widget:

-browsecmd => callback

The callback is called when the user browses through the entries in the TList. Use -command if you want to invoke a callback when a user selects an item in the TList.

-itemtype => ' text ' | 'imagetext' | 'image' | 'window'

The default item type to use for the TList. This allows you to call insert without specifying an item type, as it will use the one specified here.

-orient => ' vertical ' | 'horizontal'

A TList will create columns if it can’t fit everything in the first column. This option specifies if the items are ...

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