A listbox is a widget that displays a list of single line strings. One or more of the strings may be selected through using the mouse. Initializing and manipulating the contents of a listbox is done through invoking methods on the instance of the listbox. As examples, the insert method is used to insert a string into a listbox, delete to delete one, and get to retrieve a particular entry. Also the currently selected list items can be retrieved through the selection command.

Here is an example of a listbox that is filled with entries of the form entry N:

     listbox .l
     for { set i 0 } { $i<10 } { incr i } {
         .l insert end "entry $i"

A listbox may be given a height and/or width attribute, in which case it is likely that not all of the strings in the list are visible at the same time. There are a number of methods for affecting the display of such a listbox.

The see method causes the listbox display to change so that a particular list element is in view. For example,

     .l see 5

will make sure that the sixth list item is visible. (List elements are counted from element 0.)