Re: Tklib's tooltip poss bug in method although fine in a function

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Tklib's tooltip poss bug in method although fine in a function
De : gregor.ebbing (at) *nospam* gmx.de (greg)
Groupes : comp.lang.tcl
Date : 13. Jul 2024, 17:21:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6u9j3$3lknd$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Am 13.07.24 um 12:50 schrieb Mark Summerfield:
In the script below, clicking button two works fine, but even hovering
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)
Hello,
With tcl 8.6 with the helpers proc callback engine there is no error message.
The error occurs in 9.0.
As far as I understand, the handling has become more restrictive under 9.0.
With after idle the call is outside the method.
(My interpretation! Trial and error method)
method add_one {} {
         .toolbar add [ttk::button .toolbar.one -text One \
             -command [callback on_one]]
         after idle [list ::tooltip::tooltip .toolbar.one "One fails on tooltip"]
     }

Date Sujet#  Auteur
13 Jul 24 * Tklib's tooltip poss bug in method although fine in a function14Mark Summerfield
13 Jul 24 `* Re: Tklib's tooltip poss bug in method although fine in a function13greg
13 Jul 24  `* Re: Tklib's tooltip poss bug in method although fine in a function12undroidwish
13 Jul 24   +- Re: Tklib's tooltip poss bug in method although fine in a function1undroidwish
14 Jul 24   `* Re: Tklib's tooltip poss bug in method although fine in a function10Harald Oehlmann
14 Jul 24    +* Re: Tklib's tooltip poss bug in method although fine in a function4greg
14 Jul 24    i`* Re: Tklib's tooltip poss bug in method although fine in a function3Harald Oehlmann
15 Jul 24    i `* Re: Tklib's tooltip poss bug in method although fine in a function2undroidwish
15 Jul 24    i  `- Re: Tklib's tooltip poss bug in method although fine in a function1Harald Oehlmann
15 Jul 24    `* Re: Tklib's tooltip poss bug in method although fine in a function5Mark Summerfield
15 Jul 24     `* Re: Tklib's tooltip poss bug in method although fine in a function4Mark Summerfield
15 Jul 24      `* Re: Tklib's tooltip poss bug in method although fine in a function3Harald Oehlmann
15 Jul 24       `* Re: Tklib's tooltip poss bug in method although fine in a function2Mark Summerfield
15 Jul 24        `- Re: Tklib's tooltip poss bug in method although fine in a function1Harald Oehlmann

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal