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


COMB WIDGET EXAMPLES

Pull-down List. A pull-down list (pdl) is a comb-widget that consists of an entry, a label, a button, and a pull-down listbox with a vertical scrobar. A text string can be entered either by typing into the entry widget, or by selecting an item from the pull-down list. The label sub-widget is an option that is specified in the widget creation. 

EXAMPLE: The following example creates a frm and then adds a pdl into it. The contents of the pdl widget are initialized with a list {File1 File2 ... File0}. 

catch "destroy .pdl"
update
toplevel .pdl
global pdltext
set frm [frm.create .pdl.frm -label {-text pdl}]
set pdl [frm.add $frm -pdl pdl.create "\
    -label {-text File:} \
    -ent {-width 6 -textv pdltext}"]
pdl.setList $pdl {\
    File1 File2 File3 File4 File5 \
    File6 File7 File8 File9 File0}
pdl.bind $pdl <Return> {global pdltext; puts $pdltext} -ent 
pack $frm -expand 1 -fill both
pack $pdl -expand 1 -fill both -pady 2

An example a pdl widget 

CLASS NAME: pdl

COMB-WIDGET OPTIONS

-ent options It specifies options of an Entry to accept input from the keyboard. Pressing an <Return> completes a selection. 
-btn options It specifies options of a Button that may pressed to open the pull-down listbox. If the listbox has been opened, pressing and then releasing the button will close it. If the button releasing closes the listbox, it triggers any scripts that are bound to the <Return> event of the -ent
-label options It specifies options of a Label to display a text label at the left side of the entry. This sub-widget is optional. It is only created when the option is specified during the widget creation. 
-list options It specifies options of a pull-down Listbox. Clicking an item in the pull-down listbox will select it into the entry. Double click an item completes two things: firstly, it selects the item into the entry; secondly, it triggers any scripts that are bound to the <Return> event of the -ent. Any second clicking outside the listbox will close the listbox. 
-scrb options It specifies options of a Scrollbar to scroll the contents of the listbox up and down in browsing the whole listbox. 
WIDGET API
pdl.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 pdl widget. If the event is not specified, the current event that was bound to the sub-widget 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. 
pdl.cget pathname -varName. This command retrieves the value of the -varName for a pdl widget. If the pathname must refer to a pdl widget. 
pdl.config pathname ?options? This command configures options of a pdl widget referred to by the pathname. If the ?options? is not specified, a list of the pdl 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 configuraiton. 
pdl.create pathname ?options? This command creates a pdl widget with the given options. If the pdl widget is successfully created, the pathname is returned. Otherwise, an empty string is returned. 
pdl.delItmes pathname index1 index2. This command deletes items of a pdl widget from index1 to index2. If index2 is not specified, it is defaulted to index1
pdl.getEntry pathname. This command retrieves the entry's text of a pdl widget. 
pdl.getList pathname index1 index2. This command retrieves the items in the listbox of a pdl widget. If both index1 and index2 are not specified, all the items in the listbox are returned. 
pdl.insItems pathname position items. This command inserts a list of items to a pdl widget at the specified position. 
pdl.setEntry pathname text. This command sets the entry of a pdl widget with the text. 
pdl.setList pathname items. This command sets the listbox of a pdl widget with the a list of items. The old contents of the listbox are replaced. 
RELATED PROCEDURES

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

pdl.abort pathname
pdl.closeList pathname
pdl.createList pathname
pdl.free pathname
pdl.listTest 
pdl.openList pathname
pdl.selList pathname x y
[HOME] [CONTENTS] [DOWNLOAD]