[HOME][CONTENTS][DOWNLOAD][PREV][NEXT]


COMB WIDGET EXAMPLES

Scroll List Box. A scroll list box (slis) is a comb-widget that consists of a listbox, a vertical and/or a horizontal scrollbars. An initial list can be specified in a widget creation, and the contents of the listbox can be set or retrieved after the widget creation. 

EXAMPLE: The following example creates a frm widget and then adds an slis widget into the frm widget. The slis widget is configured with a vertical scrollbar and a list of ten items. 

catch "destroy .slis"
set w .slis
toplevel $w
wm title $w slis
set slis [frm.create $w.slis -label {-text slis}]
pack $slis -expand 1 -fill both
pack [frm.add $slis -slis slis.create "\
    -list {-width 8} -layout v -items {\
     item0 item1 item2 item3 item4 \
     item5 item6 item7 item8 item9}"] \
    -expand 1 -fill both -pady 2 
An example of slis widget 
CLASS NAME: slis

COMB-WIDGET OPTIONS

-list options It specifies options of a Listbox to contain multiple items that can be selected by clicking the left button of the mouse. 
-scrbv options It specifies options of a Scrollbar as a vertical scrollbar to browse the contents of the listbox in vertical direction. Creation of this sub-widget may be, however, optional depending on the value of -layout
-scrbh options It specifies options of a Scrollbar as a horizontal scrollbar to browse the contents of the listbox in horizontal direction. Creation of this sub-widget may be, however, optional depending on the value of -layout. 
-items itemsList It specifies a list of items for the listbox to be initialized. This option is only available in the widget creation. After the widget is created, the command slis.setListpathname items pos may be used to reset the items in the listbox. 
-layout layoutOption It specifies an option for the widget's layout. It is only used in a widget creation. The value of this option are v, h, vh or hv. A value of v creates a widget with a vertical scrollbar only; a value of h creates a widget with a horizontal scrollbar only; and a value of either vh or hv creates a widget with both horizontal and vertical scrollbars. The default value for the -layout is v
WIDGET API
slis.bind pathname event scripts -varName. This command binds the event of the sub-widget referred to by the -varName to the scripts. The pathname must refer to a slis widget. If the event is not specified, the current event that was bound to the sub-widget is returned. If the scripts is not specified, the current scripts bound to the event is returned. The scripts may be appended to the current ones if "+scripts" is specified instead of "scripts". If the -varName is not specified, the command bind pathname event scripts is invoked. 
slis.cget pathname -varName. This command retrieves the value of the -varName for a slis widget. The pathname must refer to a slis widget. The available -varNames are: -list, -scrbv, and -sccrbh
slis.config pathname ?options?. This command configures options of a slis widget referred to by the pathname. If the ?options? is not specified, a list of the slis widget configuration is returned. Each element of the list is a list that provides information of a configurable option. The first element of a configurable option list is always the -varName. The rest of the contents depend on what the -varName refers to. If the -varName refers to a regular variable, the second element that is also the last element is the value for that variable. If the -varName refers to a sub-widget, the second element is the pathname of the sub-widget, the third is the class name, and the fourth that is also the last is the options used in previous widget creation or configuration. 
slis.create pathname ?options?. This command creates a slis widget with the given options. If the slis widget is successfully created, the pathname is returned. Otherwise, an empty string is returned. The available options for a slis.create command are: -list, -scrbv, -scrbh, and -items
slis.getList pathname first last. This command retrieves a list of items of a slis widget. The first is the index of the first item, and the last is the index of the last item. The default values for the first and last are 0 and end respectively. 
slis.setList pathname items pos. This command inserts a list of items into the listbox. The items is a list of the items to be inserted. The pos is the index of the first item to be inserted into the listbox. 
RELATED PROCEDURES

The followings are procedures used in a slis widget implementation and test. A user may access to these procedures through the slis widget API, and should never use these procedures directly in an application program. 

slis.free pathname
slis.test pathname layout

[HOME][CONTENTS][DOWNLOAD]