Version 1 of Learning Iwidgets

Updated 2004-11-08 16:08:25 by lwv

2004/11/1 skm I am learning to use Iwidgets and will document some of the process here, in case others will find it useful.


Childsites

I found childsites to be tricky when first working with Iwidgets. The examples in the book and on the online man pages don't give enough detail for me on when and how to use childsites. Consider the example from Smith's book for the tabnotebook.

 # Create and fill in the page for tab 1. Note the pathname will
 # likely not exist on your system.
 set tab1 [.tb add -label "Itcl Powered"]
 frame $tab1.f -relief ridge -bd 3

and so on. $tab1 is a childsite. At first I was confused because he added a frame to what appeared to be the tab, rather than adding it to the tab's childsite. But, if you look at the childsite method for tabnotebook, you can see that it is associated with the notebook. So, one needs to go look at the reference for notebook to track down what this means (ed's note: and I followed a trail that I'd like to record here, but I need to get back to work, sorry) that the add method returns a handle for a childsite, not a widget, right?


Binding Behavior

I also found it tricky to add a binding to an Iwidget, and someone directed me to the component method. Smith discusses this in chapter 11, pg. 341.

I made a scrolledcanvas

    set sc [iwidgets::scrolledcanvas $tab1.sc \
            -borderwidth 2 \
            -width $w \
            -height $h \
            ]

and couldn't get bindings to properly work on the canvas until I bound them on $sc component canvas. Maybe this seems obvious now, but it wasn't when I first had the question. (for a while, I got the binding behavior I expected by binding to the childsite of the scrolledcanvas rather than the scrolledcanvas. I must rootcause this and add explanation here)


See also incr tcl and incr widgets.


Category Tutorial