There are two ways in which widgets can be identified by a script: the wid returned on the creation of an object, and the use of the -name option. In both instances the interpretor will make an association betweem the two parameters and treat them as commands.
Now, consider what can be done if its necessary to hold meta information about a widget. At first one might think of using the -data option, which is fine up to a point. But, if the script needs access to a parameter of some sort that is passed to a callback handler then the obviouse choice is the use of the -data option. Doing so would allow that data to be accessed using the %p substitution parameter.
The glib apl allows us to assign various named string values to any g object. This could be anything, a desciption of the widget, some criteria which may result in the selective packing of widgets into a container. Perhaps even a tagged list.
The following code snippet shows how such data can be assigned, retrieved and manipulated.
set wid(1) [gnocl::widget-class]
# create associated data field "tags" and initalize it to some value
gnocl::data $wid(1) set tags $myTag1
# append the contents of the "tags" data string
gnocl::data $wid(1) set tags [list [gnocl::data $wid(1) get tags] $myTag2]
Subscribe to:
Post Comments (Atom)
-
Given this module some attention today. Added some of the more package wide options to the module and created customised handler for settin...
-
Spent some time today creating some simple howto-tutorials on creating standalone Tcl/Gnocl applications using freewrap. The process is almo...
-
Linux distros have heaps of pre-installed icons ready for use. I recently needed to create a toolbar menu which needed to access a set of un...
No comments:
Post a Comment