Liste des Groupes | Revenir à cl tcl |
In the script below, clicking button two works fine, but even hoveringHello,
over button One produces an error (shown at the end).
The difference is that button one's tooltip is created in a method and
button two's tooltip is created in a function. If you comment out button
one's tooltip, the button works fine just like button two. I'm using Tcl/
Tk 9.0b2 on Linux.
#!/usr/bin/env wish9
package require tooltip
package require widget::toolbar
if {[info exists env(TK_SCALING)]} {tk scaling $env(TK_SCALING)}
proc main {} {
tk appname "Tooltip Bug?"
set application [App new]
$application show
}
namespace eval toolbar {}
proc toolbar::add_two app {
.toolbar add [ttk::button .toolbar.two -text Two \
-command [list $app on_two]]
::tooltip::tooltip .toolbar.two "Two works fine"
}
oo::class create App {}
oo::define App {
constructor {} {
wm withdraw .
wm title . [tk appname]
widget::toolbar .toolbar
my add_one
toolbar::add_two [self]
pack .toolbar
bind . <Escape> {destroy .}
}
method add_one {} {
.toolbar add [ttk::button .toolbar.one -text One \
-command [callback on_one]]
::tooltip::tooltip .toolbar.one "One fails on tooltip" ;# BUG
}
method on_one {} { puts "on_one" }
method on_two {} { puts "on_two" }
method show {} { wm deiconify . ; raise . }
}
main
Here is the bug that arises when hovering over button one. Note that if
you comment out the ";# BUG" line, button one works fine.
self may only be called from inside a method
self may only be called from inside a method
while executing
"self"
("uplevel" body line 1)
invoked from within
"uplevel 2 { self }"
(procedure "PackageNamespaceGet" line 17)
invoked from within
"PackageNamespaceGet"
(procedure "::msgcat::mc" line 2)
invoked from within
"::msgcat::mc {One fails on tooltip}"
(in namespace eval "::oo::Obj69" script line 1)
invoked from within
"namespace eval $nscaller [list ::msgcat::mc $text {*}$msgargs]"
(procedure "show" line 22)
invoked from within
"show .toolbar.one {{One fails on tooltip} {} {} ::oo::Obj69 {} {}}
cursor"
(in namespace inscope "::tooltip" script line 1)
invoked from within
"::namespace inscope ::tooltip {show .toolbar.one {{One fails on tooltip}
{} {} ::oo::Obj69 {} {}} cursor}"
("after" script)
Les messages affichés proviennent d'usenet.