| GRIDPLUS - Variable Substitution in Grid Layout | ![]() |
||||||
|
| GRIDPLUS Variable Substitution in Grid/Layout |
It is possible to refer to elements in the global null named array inside a Grid/Layout.
Normally variables inside braces are not expanded. From release 1.2 GRIDPLUS will, by default, perform variable substitution (using the Tcl subst command) for the layout parameter of both the Grid and Layout GRIDPLUS command modes. This can make the code tidier and easier to read.
The gpset command can be used to set the values to be substituted.
Example:-
gpset WIN win1
gridplus window .$(WIN)
combobox .$(WIN).title -editable 0 -width 4 -textvariable (.$(WIN).title)
eval .$(WIN).title list insert end [list Mr Mrs Miss Ms]
gridplus entry .$(WIN).employee -size 8 -title Employee {
{ID .id +}
{Title @$(WIN).title}
{Name .name 25}
{Age .age 3}
{Salary .salary}
}
gridplus button .$(WIN).buttons {
{Find .find} {Exit .exit}
}
gridplus layout .$(WIN).main -title "Test - $(WIN)" {
.$(WIN).employee
.$(WIN).buttons:ew
}
pack .$(WIN).main
This example creates a toplevel window called "win1" with some entry fields, a combobox and a couple of buttons. The name of the toplevel window is set (using "gpset WIN win1") in the null named array element "WIN". Subsequently this variable is used when a reference to the toplevel window is required.
| Disabling Variable Substitution in Grid/Layout |
Variable substitution can be disabled either globally, by using the option database...
option add *Gridplus.subst 0
...or for a specific command, by using the -subst option.