Reputation: 8037
I just started to learn tcl and it might be relevant that I'm using python's tkinter interpreter. But it should be the same, as far as I can tell.
However, I'm using pretty much the same code from the tcler's wiki but the bounded procedure never gets executed. The toplevel is created and responsive, but moving or resize the window which is parsed to $win
will not trigger the <Configure>
event. It does not fail with an error the procedure just never gets called. Could be something obvious, but I just don't see it.
namespace eval MyTk {
variable TracedWindows {}
proc StickTo {win w h x y} {
wm geometry $win.sub $wx$h+$x+$y
}
proc TraceWindow {win {value true}} {
set name $win
if {$win == "."} {set name ""}
if {$value && $win ni $MyTk::TracedWindows} {
toplevel $name.sub
bind $win <Configure> {$MyTk::StickTo %W %w %h %X %Y}
}
}
}
update, the following works. So it has to do with my namespace or how I address it:
bind $win <Configure> {bell}
Upvotes: 1
Views: 151
Reputation: 8037
Basically I found out that if you fail, for whatever reason, in your bounded procedure you won't get an error and it just don't work. Coming from python this is a bit surprising but now that I know, I can deal with it.
I used this code BTW:
bind $win <Configure> {::MyTk::StickTo %W}
and:
proc StickTo {widget} {
set name $widget
if {$widget == "."} {set name ""}
wm geometry $name.sub [wm geometry $widget]
I used the command bell
in the proc
and added line by line to make it work. One needs to code tcl with greater care as it seems.
Upvotes: 1