hwtk::selectlist

Creates a SelectList object.

Format

hwtk::selectlist - pathName ?option value? …

Standard Options

-clientdata
Database name: clientData
Database class: ClientData
Acts as a data storage for a widgets. User can store any data and this will not have any effect on widget property.
-height
Database name: height
Database class: Height
If specified, the widget’s requested height in pixels.
-helpcommand
Database name: helpcommand
Database class: Command
Dynamic help which calls an assigned -helpcommand when the user moves the mouse on the widget. The text which is returned by the -helpcommand will be in turn be displayed on the tooltip.
-relief
Database name: relief
Database class: Relief
Specifies the 3D effect desired for the widget. Acceptable values are raised, sunken, flat, ridge, solid, and groove. The value indicates how the interior of the widget should appear relative to its exterior; for example, raised means the interior of the widget should appear to protrude from the screen, relative to the exterior of the widget.
-width
Database name: width
Database class: Width
Specifies the width of a widget.

Widget Specific Options

-backgroundimage
Database name: backgroundImage
Database class: BackgroundImage
Specifies the name of an image to draw as the list background.
-closeeditor
Database name: closeeditor
Database class: Closeeditor
Boolean option when set to true, the editor unposts upon successful set value. Default is set to false.
-itemactivecommand
Database name: itemactivecommand
Database class: Command
Tcl script that will be executed when the item is activated.
-listener
Database name: listener
Database class: ActionListener
Action listener object. You can derive the hwtk::interface::HWTreectrllistener and create a class where you can overwrite the methods for all actions (such as events like Selection, ButtonPress, KeyPress, etc...).
-menu
Database name: menu
Database class: Menu
Context menu posted for RMB (Right Mouse Button) on Listbox.
-selectcommand
Database name: selectcommand
Database class: Command
Tcl script executed on selection in the Listbox. %-char substitutions are:
%w
Widget path
%S
Selected items
%c
Count (number of items selected)
-selectionindicator
Database name: selectionindicator
Database class: SelectionIndicator
Checkbutton will be displayed against each item in the Listbox. You can select items by clicking on checkbutton. This can be configured as auto, show, or hide; defaults to show.
-selectmode
Database name: selectmode
Database class: SelectMode
Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either single, or multiple. The default value is multiple.
-showheadermenu
Database name: showheadermenu
Database class: ShowHeaderMenu
Specifies a boolean value that determines whether the you can change what columns are visible by a menu that is brought up by right-clicking the header.
-statusbar
Database name: statusbar
Database class: Statusbar
Specifies a boolean value that determines whether this widget should display status bar or not; defaults to true.
-stripes
Database name: stripes
Database class: Stripes
Specifies the boolean value that determines whether this widget should draw background stripes; defaults to true.

Widget Commands

pathName cget option
Returns the current value of the configuration option given by option.
pathName columnadd columnDesc ?arg arg …?
This command is similar to the configure widget command except that it modifies options associated with the columns specified by the columDesc (tag).
-visible
Boolean
Defaults to true
-sort
Boolean
Defaults to true
-text
Column header
-image
Column header image
-itemjustify
Justify the items in the column (defaults to left)
-justify
Justify column title (default left)
-expand
Boolean
Defaults to true
-width
Width of column
-headermenu
Context menu for RMB on column header
pathName columncget columnDesc option
Returns configuration value for a column tag and option.
pathName columndelete columnDesc
Delete column form the widget. all will delete all columns.
pathName columnexists columnDesc
Returns true if the column already exists in the widget; false otherwise.
pathName columnlist
Returns list of columns in the widget.
pathName configure ?option? ?value option value …?
Query or modify the configuration options of the widget. 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. If option is specified with no value, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. If no option is specified, returns a list describing all of the available options for pathName.
pathName fittocontent
Size the selectlist to show all content.
pathName identify element x y
Returns the name of the element under the point given by x and y, or an empty string if the point does not lie within any element. x and y are pixel coordinates relative to the widget. Some widgets accept other identify subcommands.
pathName instate statespec ?script?
Test the widget’s state. If script is not specified, returns 1 if the widget state matches statespec and 0 otherwise. If script is specified, equivalent to
if{[pathNameinstatestateSpec]}script
pathName reqheight
Return the height required by the widget. More accurate than winfo reqheight.
pathName reqwidth
Return the width required by the widget. More accurate than winfo reqwidth.
pathName rowadd tag ?arg arg …?
Add new row in select list widget. For example, pathName rowadd tag value tag1 value1 will add two items to the selectlist with the tags tag tag1.
pathName rowcget rowDesc option
Returns the value for a given configuration option.
pathName rowconfigure rowDesc ?arg arg …?
Configures the row given by rowDesc. Valid options are -values, -background or -foreground. Arguments for -values must be given in the form of “[list column1 value1 column2 value2 …]”.
pathName rowdelete rowDesc ?arg arg …?
Deletes the given row tag from the widget. all deletes all the rows from the widget
pathName rowexists item
Returns a 1 if the given tag exists in the widget, 0 otherwise.
pathName rowlist
Returns list of item tags exists in the widget.
pathName see itemDesc
Updates the SelectList widget so that the item specified by itemDesc is visible. If the item is already visible in the list, this command has no effect; otherwise, the widget will scroll appropriately.
pathName selectionadd itemDesc
Adds the given tag to the selection in the widget and the selection command will be executed.
pathName selectionclear ?arg arg …?
Deselects the given tag from the selection. If all supplied all the items will be deselected
pathName selectionget ?arg arg …?
Returns the list of items which are in the selection.
pathName selectioninverse
Reverses the selection in the widget.
pathName setactive item
Sets item to the active state, same as if it was clicked.
pathName state ?stateSpec?
Modify or inquire widget state. If stateSpec is present, sets the widget state: for each flag in stateSpec, sets the corresponding flag or clears it if prefixed by an exclamation point. Returns a new state spec indicating which flags were changed:
setchanges[pathNamestatespec]
pathNamestate$changes
will restore pathName to the original state. If stateSpec is not specified, returns a list of the currently-enabled state flags.
pathName typelist
Displays a list of available editor types.

Example

set w [::hwtk::dialog .dialog -title "selectlist demo"] 
$w hide apply;
set recess [$w recess]

namespace eval ::texample {};

proc ::texample::OnSelect {W S c} {
    {puts [info level 0]
}

hwtk::selectlist $recess.s1 -stripes 1 -selectmode multiple -selectcommand "::texample::OnSelect %W %S %c"
pack $recess.s1 -fill both -expand true;
$recess.s1 columnadd entities -text Entities
$recess.s1 columnadd id -text Id
$recess.s1 columnadd color -image palette-16.png
$recess.s1 columnadd thickness -text Thickness

for {set i 0} {$i < 100} {incr i} {
    set clr [expr {int(rand()*64)}]
    $recess.s1 rowadd row$i -values [list entities "comp $clr" id $i color [expr {$clr ? $clr : 1}] thickness $i.$i$i]
{
$w post