Next: Chaining Methods Up: Standard Initialization Methods Previous: Standard Initialization Methods


The InitWidgetRec Method 

The purpose of the InitWidgetRec method is to initialize the variables of the widget instance. For example, the following implementation of tixArrowButton:InitWidgetRec sets the count variable of each newly created instance to zero.

proc tixArrowButton:InitWidgetRec {w} {
upvar #0 $w data

set data(count) 0

Earlier, we showed how each widget you create is associated with an array of the same name. Within the methods, you always refer to this array through the name data -the method then works properly in each instance of the widget.