NAME
ListBox - a listbox widget
SYNOPSIS
ListBox pathName ?option value...?
DESCRIPTION
STANDARD OPTIONS
-background or -bg
-borderwidth or -bd
-cursor
-disabledforeground
-foreground or -fg
-font
-highlightbackground
-highlightcolor
-highlightthickness
-relief
-selectbackground
-selectforeground
-takefocus
-xscrollcommand
-yscrollcommand
WIDGET-SPECIFIC OPTIONS
-autofocus (read-only)
-deltax
-deltay
-dragenabled
-dragendcmd
-dragevent
-draginitcmd
-dragtype
-dropcmd
-dropenabled
-dropovercmd
-dropovermode
-droptypes
-height
-multicolumn
-padx
-redraw
-selectfill (read-only)
-selectfilly (read-only)
-selectmode
-state
-width
WIDGET COMMAND
pathName bindImage event script
pathName bindText event script
pathName cget option
pathName configure ?option? ?value option value ...?
pathName delete ?arg...?
pathName edit item text ?verifycmd? ?clickres? ?select?
pathName exists item
pathName index item
pathName insert index item ?option value...?
pathName item first ?last?
pathName itemcget item option
pathName itemconfigure item ?option? ?value option value ...?
pathName items ?first? ?last?
pathName move item index
pathName reorder neworder
pathName see item
pathName selection cmd ?arg...?
pathName xview ?arg...?
pathName yview ?arg...?
BINDINGS

NAME

ListBox - a listbox widget

SYNOPSIS

ListBox pathName ?option value...?

DESCRIPTION

The ListBox widget uses a Tk canvas to display a list of items. Each item is composed of a text label with its own font and foreground attributes, and an optional image or window. Each item is drawn in a single line, whose height is defined by the -deltay option, so they must have at most this height. A item is uniquely identified by a string given at creation (by the insert widget command). The ListBox can have one or more columns, depending on its -multicolumn option. The user does not handle columns; the number of columns is determined by the height of the ListBox and the number of items, in order to map each item within the specified vertical space.

The ListBox widget is used by Slab ComboBox, and thus by SelectFont.

WIDGET-SPECIFIC OPTIONS

"Read-only" options must be supplied as arguments to the ListBox command. The values of these options cannot be changed later by calling the configure widget command.

-autofocus (read-only)
If this option is true, the ListBox will take focus any time the user clicks in it. Without focus, the ListBox's mouse wheel bindings will not work properly. The default is true.
-deltax
Specifies horizontal pad between each columns.
-deltay
Specifies vertical size of the items.
-dragenabled
A boolean specifying if drag is enabled.
-dragendcmd
Specifies a command to be called when drag ended. -dragendcmd must be a command conforming to the description of the option -dragendcmd of DragSite::register.
-dragevent
Specifies the number of the mouse button associated to the drag. Must be 1, 2 or 3.
-draginitcmd
ListBox has a command wrapper for drag-init events. This command refused the drag if no item is designated. In other cases:
If -draginitcmd is empty, it returns: If -draginitcmd is not empty, it is called with the following arguments: and must return a value conforming to -draginitcmd option described in DragSite::register.
-dragtype
Specifies an alternate type of dragged object.
-dropcmd
ListBox has a command wrapper for drop events. This command stops auto scrolling and extract item and position.
If -dropcmd is not empty, it is called with the following arguments: The default drop command allows for drag-and-drop within the ListBox but not to or from other widgets.
-dropenabled
A boolean specifying if drop is enabled.
-dropovercmd
ListBox has a command wrapper for drag-over events. This command enables auto scrolling and position extraction during the drag-over. If -dropovercmd is not empty, the command is called with the following aguments: The command must return a list with two elements:
-dropovermode
Specifies the type of drop-over interaction. Must be a combination of w, which specifies that drop can occurs everywhere on widget, p, which specifies that drop can occurs between two items, and i, which specifies that drop occurs inside items.
-droptypes
Specifies a list of accepted dropped object/operation. See option -droptypes of DropSite::register. for more infromation.
Default is LISTBOX_ITEM with operations copy and move.
-height
Specifies the desired height for the ListBox in units of -deltay pixels.
-multicolumn
Specifies whether or not ListBox layouts items in order to see each one vertically.
-padx
Specifies distance between image or window and text of the items.
-redraw
Specifies whether or not the ListBox should be redrawn when entering idle. Set it to false if you call update while modifying the ListBox.
-selectfill (read-only)
If true (and if option -multicolumn is false), the ListBox will draw a selection rectangle that fills the ListBox from left-to-right instead of just drawing a box around the selected item. This more closely mimics the standard Tk ListBox.
-selectfilly (read-only)
If true (and if option -multicolumn is false), the ListBox will draw a selection rectangle that fills the space available to the item from top-to-bottom instead of just drawing a box around the selected item.
-selectmode
Specifies the desired selection-mode for the ListBox. Must be one of none, single or multiple. -selectmode single allows to select 1 item by its text or image. -selectmode multiple allows to select multiple items by their text or image. For more information on -selectmode values single and multiple, see the Tk listbox command. The default value for -selectmode is none.
-state
Specifies whether the widget is normal or disabled. Other values used elsewhere in Tk (active, hidden) are not supported.
-width
Specifies the desired width for the ListBox in units of 8 pixels.

WIDGET COMMAND

pathName bindImage event script
This command associates a command to execute whenever the event sequence given by event occurs on the image of a item. The item identifier on which the event occurs is appended to the command.

Any occurrence of %W in script is substituted with the path of the ListBox.

The command is not executed if the item's -state is disabled.
pathName bindText event script
This command associates a command to execute whenever the event sequence given by event occurs on the text label of a item. The item identifier on which the event occurs is appended to the command.

Any occurrence of %W in script is substituted with the path of the ListBox.

The command is not executed if the item's -state is disabled.
pathName cget option
Returns the current value of the configuration option given by option. Argument option may have any of the values accepted by the creation command ListBox.
pathName configure ?option? ?value option value ...?
Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName. If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Argument option may have any of the values accepted by the creation command ListBox. Read-only options cannot be modified.
pathName delete ?arg...?
Deletes all items in arg. arg can be a list of items or a list of list of items. To delete all items, do $pathName delete [$pathName items].
pathName edit item text ?verifycmd? ?clickres? ?select?
Provides a way for the user to edit in place the text label of an item.
The command takes the initial text as argument and does not modify the text label of the edited node, but returns an empty string if editing is canceled, or the typed text if editing is accepted.
When editing, the user can cancel by pressing Escape, or accept by pressing Return.
clickres specifies what to do if the user click outside the editable area. If clickres is 0 (the default), the editing is canceled. If clickres is 1, the editing is accepted. In all other case, the editing continues.
If editing is accepted and verifycmd is not empty, then it is called with the new text as argument and must return 1 to accept the new text, 0 to refuse it and continue editing.
select specifies whether or not the initial text should be selected. Default is 1.
pathName exists item
Returns 1 if item exists in the ListBox, else 0.
pathName index item
Returns the position of item in the list; or, if item is not in the list, -1 or {} in Tk 8 or 9 respectively.
pathName insert index item ?option value...?
Inserts a new item identified by item in the list at position index.

Any instance of #auto within the item name will be replaced by the number of the item in the order of insertion.

Arguments option can take these values:

-data
User data associated to the item.
-disabledfill
Specifies the foreground color of the item text when its -state is disabled.
-disabledimage
Specifies an image. If provided, this image will be displayed when the item's -state is disabled, instead of the image specified by -image.
-fill
Specifies the foreground color of the item text when its -state is normal.
-font
Specifies a font for the text label of the item.
-helpcmd
Has no effect. See also DynamicHelp.
-helptext
Text for dynamic help. If empty, no help is available for this item. See also DynamicHelp.
-helptype
Type of dynamic help. Use balloon (the default for a ListBox item) or variable. See also DynamicHelp.
-helpvar
Variable to use when -helptype option is variable. See also DynamicHelp.
-image
Specifies an image to display at the left of the text label of the item. The -window option overrides -image.
-indent
Specifies the amount of extra space in pixels at the left of the item.
-state
Specifies whether the item is normal or disabled. Other values used elsewhere in Tk (active, hidden) are not supported.

If the item is disabled, its image will be specified by -disabledimage (if defined) in preference to -image, the color of its text will specified by -disabledfill rather than -fill, the item will not be selectable, and the bindings defined by the widget commands bindImage and bindText will not fire.
-text
Specifies the text that labels the item.
-window
Specifies the Tk pathname of a window to display at the left of the text label of the item. If a window is displayed, the -image and -disabledimage options are ignored.
pathName item first ?last?
Its use is deprecated. Use items instead.
If last is omitted, returns the item at index first in the list, or an empty string if first refers to a non-existent element. If last is specified, the command returns a list whose elements are all of the items between first and last, inclusive. Both first and last may have any of the standard forms for indices.
pathName itemcget item option
Returns the current value of a configuration option for the item. Argument option may have any of the values accepted by the item creation widget command insert.
pathName itemconfigure item ?option? ?value option value ...?
This command is similar to the configure command, except that it applies to the options for an individual item, whereas configure applies to the options for the widget as a whole. Argument option may have any of the values accepted by the item creation widget command insert. If options are specified, options are modified as indicated in the command and the command returns an empty string. If no options are specified, returns a list describing the current options for the item. Read-only options cannot be modified.
pathName items ?first? ?last?
If first and last are omitted, returns the list of all items. If first is specified and last omitted, returns the item at index first, or an empty string if first refers to a non-existent element. If first and last are specified, the command returns a list whose elements are all of the items between first and last, inclusive. Both first and last may have any of the standard forms for indices.
pathName move item index
Moves item at position index in the list.
pathName reorder neworder
Modifies the order of items in the ListBox given by neworder. Items that do not appear in neworder are no moved.
pathName see item
Arrange the scrolling area to make item visible.
pathName selection cmd ?arg...?
Modifies the list of selected items following cmd:
clear
remove all items of the selection.
set
set the selection to all items in arg
add
add all items of arg in the selection
remove
remove all items of arg of the selection
get
return the current selected items
pathName xview ?arg...?
Standard command to enable horizontal scrolling of pathName.
pathName yview ?arg...?
Standard command to enable vertical scrolling of pathName.

BINDINGS

A <<ListboxSelect>> virtual event is generated any time the selection in the ListBox changes.

The ListBox has all the standard mouse wheel bindings when it has focus.

Copyright © 1998-1999 UNIFIX.
Copyright © 2001-2002 ActiveState Corp.
Copyright © 2017-2025 CitizenEarth Internet Ltd.