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]
Thursday, October 11, 2018
Subscribe to:
Posts (Atom)
-
Given this module some attention today. Added some of the more package wide options to the module and created customised handler for settin...
-
Over the past few programming sessions I've been working on producing a central point, a dashboard, around which it's possible to se...
-
The contents of a GtkTextBuffer can be saved as serialized binary file. Whilst converting such a file to ascii may be problematic if the bu...