Overview
| Artifact ID: | 44bb112b20177cb01d7970e38b2c5cc2f757ec36d8f061ed12b9591fc20d374b |
|---|---|
| Ticket: | 91b3a5bb14e6e8ae1d1c5349af12e08879ea152d
msgcat with oo: error "self may only be called from inside a method" |
| User & Date: | oehhar on 2024-07-14 13:38:01 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
MSGCat may issue an error with the following stack trace: <verbatim> 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::Obj135" 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::Obj135 {} {}} cursor" (in namespace inscope "::tooltip" script line 1) invoked from within "::namespace inscope ::tooltip {show .toolbar.one {{One fails on tooltip} {} {} ::oo::Obj135 {} {}} cursor}" ("after" script)</verbatim> Mark described on clt how to show this: 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. <verbatim> #!/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 </verbatim> Note that if you comment out the ";# BUG" line, button one works fine. ----- Any idea welcome. This ticket may be of relevance: [e02798626dfbcd7b33db] The eventually relevant Tklib ticket is [https://core.tcl-lang.org/tklib/info/3300362]. Thank you, Harald - foundin changed to: "main"
- is_private changed to: "0"
- login: "oehhar"
- priority changed to: "5 Medium"
- private_contact changed to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "oehhar"
- subsystem changed to: "30. msgcat Package"
- title changed to:
msgcat with oo: error "self may only be called from inside a method"
- type changed to: "Bug"