String Container. A string container (str) is a comb-widget that consists of an entry, a label or a button, or both. It allows a user to input a string and then to press a button to execute a related command. Additional sub-widgets may be added into a str widget as needed. EXAMPLE: The following example creates a frm widget and then adds a str widget into it. The str widget has an entry and a button. The button is configured with a command that prints the contents of the entry when the button is pressed. catch "destroy .str" A str widget CLASS NAME: str COMB-WIDGET OPTIONS -ent options It specifies options of an Entry to accept input from the key-board. Pressing an <Return> key may trigger an execution of the command configured for the button. -btn options It specifies options of a Button to configure a command that is executed with the input from the entry by pressing this button. This sub-widget is optional. -label options It specifies options of a Label to inform the user about what is expected to be typed into the entry. This sub-widget is optional. -padx PADX This is an option for the widget creation only. It is used as a value of the -padx option in sub-widget packing by str.create. -pady PADY This is an option for the widget creation only. It is used as a value of the -pady option in sub-widget packing by str.create. -layout LAYOUT This is an option for the widget creation only. It is used as a value of the -side option in sub-widget packing by str.create. Only two values are allowed: right and left. A value of right packs the sub-widgets in the order from right to left: Entry, Button and Label. A value of left packs the sub-widgets in the reversed order from left to right: Label, Button and Entry.WIDGET API str.add pathname -varName creator ?options?. This command adds a new widget into the str widget referred to by pathname. The -varName is used to refer to the newly added sub-widget. The creator specifies the name of the creation procedure of the newly added widget and options is a list of options of the newly created widget. str.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 str 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 bindpathname event scripts is invoked. str.cget pathname -varName. This command retrieves the value of the -varName for a str widget. The pathname must refer to a str widget. The available -varNames are: -ent, -btn, and -label<. str.config pathname ?options?. This command configures options of a str widget referred to by the pathname. If the ?options? is not specified, a list of the str 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. str.create pathname ?options?. This command creates a str widget with the given options. If the str widget is successfully created, the pathname is returned. Otherwise, an empty string is returned. The available options for num.create are: -ent, -label, -btn, -padx>, -pady, and -layout. str.get pathname. This command retrieves the string from the sub-widget -ent. str.set pathname string. This command sets the sub-widget -ent with the specified string.RELATED PROCEDURES The followings are procedures used in str widget implementation and test. A user may access to these procedures through the str widget API, and should never use these procedures directly in an application program. str.free pathname. |