[Xotcl] Linking object instance variables to a widget -textvariable?
Catherine Letondal
letondal at pasteur.fr
Sat Nov 15 10:23:51 CET 2003
Uwe Zdun wrote:
> Hi Ken,
>
> perhaps others use other styles, but a simple way to bind variables,commands,
> or other callbacks from TK into XOTcl is replacement of "self" (or "my") from
> within a XOTcl method. Example:
>
> Class BrowserTree
> BrowserTree instproc init args {
> ...
> set tree [Tree $sw.tree \
> -relief flat -borderwidth 0 -width 15 -highlightthickness
> 0\
> -redraw 0 -dropenabled 1 -dragenabled 1 \
> -dragevent 3 \
> -droptypes {
> TREE_NODE {copy {} move {} link {}}
> LISTBOX_ITEM {copy {} move {} link {}}
> } \
> -opencmd "[self] modifyTree 1 $sw.tree" \
> -closecmd "[self] modifyTree 0 $sw.tree"]
> ...
> $tree bindText <ButtonPress-1> "[self] selectTreeElement $tree"
> $tree bindText <Double-ButtonPress-1> "[self] openTreeElement $tree"
> ...
> }
>
> note that you cannot use curly brackets {} here, because then self would
> not be replaced within the object's scope and would likely have a wrong value
> or raise an exception.
>
> this style of binding works nicely together with XOTcl's inheritance and
> mixins
>
This work perfectly for commands, and I use it all the time, but it does not
work for variables.
In fact, I believe Tk always expect a Tcl global variable and an XOtcl
object instance variable is not a global variable, right?
So the issue is maybe : how to bind an Xotcl object instance variable
to a Tcl global variable?
Catherine
More information about the Xotcl
mailing list