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


COMB WIDGET EXAMPLES

Multi-entry. A multi-entry (ment) is a comb-widget to provide multiple entries. It is constructed with three blocks at top, middle and bottom. The top block is a title bar to display a title of a ment widget. The middle block is user-defined multiple entries. And the bottom block is a bar of user-defined buttons. 

EXAMPLE: The following example creates a ment widget with three entries for name, address and phone. Three buttons are created and configured with demonstrating scripts. 

catch "destroy .ment"
toplevel .ment
set ment [ment.create .ment.m \
    -title Multi-Entries \
    -btns {{-text Ok} {-text Cancel} {-text Quit}} \
    -vars {name address phone} \
    -values {{Chengye Mao} \
    {Bldg. 1103, Suite 118, SSC, MS 39529} \
    {(228) 688-2509}}]
foreach v {v0 v1 v2} {
    ment.config $ment -$v {-width 35}
}
ment.config $ment -btn0 "-command {puts \[ment.get $ment value\]}"
ment.config $ment -btn1 "-command {puts Cancel; bell}" 
ment.config $ment -btn2 "-command {after idle destroy .ment}" 
pack $ment -expand 1 -fill both 
An example of a ment widget 

CLASS NAME: ment

COMB-WIDGET OPTIONS

-title titleString It specifies a text string as a title at the top block of a ment widget. It is defaulted to "Enter from the key-board". 
-vars varNameList It specifies a list of the names for each entry of a ment widget. A name of an entry is always located at the left side of the entry. This option is used for widget creation only. 
-values varlueList It specifies a list of the initial values for each entry of a ment widget. An initial value of an entry may be an empty string {}. It is used to initialize the entry at the time of creation. This option is used for widget creation only and defaulted to {Input}. 
-btns btnOptions It specifies a list of the options for each button at the bottom block of a ment widget. This option is used for widget creation only and defaulted to {{-text Ok} {-text Cancel}} which defines two buttons labeled Ok and Cancel respectively. 
-v0, -v1, ..., -vn These -varNames refer to Entry widgets and are available only after a ment widget is created. Entries are create for every name specified in the default or input list of -vars. Each entry allows a user to type in a text string. A user may define the GUI for each entry by the command ment.bind and ment.config. A default binding is provided for each entry's key press. A Return or Down key press causes the focus to shift to a next entry except for the bottom entry in which a Return or Down key press causes the focus to shift to the top entry. An Up key press causes the focus to shift to an upper entry except for the top entry in which an Up key press causes the focus shift to the bottom entry. 
-btn0, -btn1, ..., -btnn These -varNames refer to Button widgets and are available only after a ment widget is created. Buttons are created for every option specified in the default or input list of -btns. These buttons are referred to with -btn0, -btn1, ..., -btnn in ment widdget commands except for ment.create. A user may define the GUI for each button by the command ment.bind or ment.config. A default binding is provided for each button such that when a Return is pressed in a focused button, it triggers an evaluation of the command that is configured for that button. 
WIDGET API
ment.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 ment 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. 
ment.cget pathname -varName. This command retrieves the value of the -varName for a ment widget. The pathname must refer to a ment widget. The available -varNames are: -title, -btn0, -btn1, ...., -btnn, -v0, -v1, -vn.
ment.config pathname ?options?. This command configures options of a ment widget referred to by the pathname. If the ?options? is not specified, a list of the ment 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. 
ment.create pathname ?options?. This command creates a ment widget with the given options. If the ment widget is successfully created, the pathname is returned. Otherwise, an empty string is returned. The available options for ment.create are: -titlte, -vars, -values, and -btns
ment.get pathname ?option?. This command returns a list of strings. Available options are var, value, nvars, and nbtns. An option of var retrieves a list of strings of all the labels. An option of value retrieves a list of strings of all the entries. An option of nvars retrieves the number of entries. And an option of nbtns retrieves the number of buttons. 
ment.set pathname text -varName. This command sets the entry referred to by the -varName with the text. The available -varNames are -v0, -v1, ..., -vn.
RELATED PROCEDURES

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

ment.free pathname
ment.keyPress pathname widget id keyName
ment.test pathname 

[HOME][CONTENTS][DOWNLOAD] 1