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'') ----- 2004/11/18 skm Boy am I confused. Why do the childsite items move when I draw items on the scrollcanvas? package require Tk package require Iwidgets proc build_scrollcanvas {} { global scrollcanvas childsite set h 300 set w 300 set scrollcanvas [iwidgets::scrolledcanvas .scrollcanvas \ -borderwidth 2 \ -width $w \ -height $h \ ] set childsite [$scrollcanvas childsite] $childsite create line -90 10 90 10 -tag cs_xaxis -width 5 -fill red $childsite create line 10 -90 10 90 -tag cs_yaxis -width 5 -fill red $childsite create rectangle 0 0 50 50 -tag foo label .childsitexy -text childsite bind $childsite {.childsitexy configure -text %x,%y} grid .childsitexy grid $scrollcanvas } proc go {} { build_scrollcanvas } proc itmoves {} { global scrollcanvas $scrollcanvas create line -100 5 100 5 -tag xaxis -width 5 -fill black $scrollcanvas create line 0 -100 0 100 -tag xaxis -width 5 -fill black } console show Type go. Type itmoves to see everything move. I specified x coords of (0,0) for the rectangle, yet it moved when I drew on the scrollcanvas instead of the childsite (which is a mistake, I know. but why does it happen?). ---- 2006-08-02 [Shin The Gin] I just subclassed ''::iwidgets::Scrolledtext'' to bind a context menu to the text component. The new class is called ''::MyClasses::Scrolledtextext''. Now, when I instanciate it like... ::MyClasses::Scrolledtextext .scext \ -textfont {Monospace 14} \ -vscrollmode dynamic \ -hscrollmode dynamic ..., the options (-textfont, -vscrollmode...) won't get set. What's the clue? Isn't subclassing enough? ----- See also [incr tcl] and [incr widgets]. ---- !!!!!! %| [Category Tutorial] | [Category Widget] | [Category Itcl] |% !!!!!!