Thread from comp.lang.tcl (13 replies)
Tklib's tooltip poss bug in method although fine in a function
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)Click on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
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"] }Click on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
On 7/13/24 18:21, greg wrote: > 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). .... >> self may only be called from inside a method .... >> "uplevel 2 { self }" >> (procedure "PackageNamespaceGet" line 17) >> invoked from within >> "PackageNamespaceGet" >> (procedure "::msgcat::mc" line 2) .... > 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. .... My humble interpretation is that the problem lies in msgcat::mc fundamentally. Wrong assumptions over call context. Independent of Tcl versions 8 or 9. But I might be mislead still. It is worth a ticket anyways. BR, ChristianClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
On 7/14/24 00:32, undroidwish wrote: >... But I might be mislead still. It is worth a > ticket anyways. And while we're at it, "man self" gives """ DESCRIPTION The self command, which should only be used from within the context of a call to a method (i.e. inside a method, constructor or destructor """ Could it be, that it should be "...which must be used..." instead of "...which should only be used..."? A documentation problem too? Otherwise clueless anyway always, ChristianClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Am 14.07.2024 um 00:32 schrieb undroidwish: > On 7/13/24 18:21, greg wrote: >> 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). > ... >>> self may only be called from inside a method > ... >>> "uplevel 2 { self }" >>> (procedure "PackageNamespaceGet" line 17) >>> invoked from within >>> "PackageNamespaceGet" >>> (procedure "::msgcat::mc" line 2) > ... >> 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. > ... > > My humble interpretation is that the problem lies in msgcat::mc > fundamentally. Wrong assumptions over call context. Independent of > Tcl versions 8 or 9. But I might be mislead still. It is worth a > ticket anyways. Dear Mark, dear Christian, yes, both, msgcat and tooltip were recently changed. Did you use tklib 0.8 release and TCL/Tk 9.0b2 ? Those tickets are in both of them: https://core.tcl-lang.org/tklib/info/3300362 https://core.tcl-lang.org/tcl/tktview/e02798626dfbcd7b33db I tried your snippet with this and can reproduce the issue. Here is the TCL ticket: https://core.tcl-lang.org/tcl/tktview/91b3a5bb14e6e8ae1d1c5349af12e08879ea152d and here the TkLib ticket: https://core.tcl-lang.org/tklib/tktview/6e85abae9e49281b3b1212e25082f73239f7ea9e I hope, we will find a solution. I am not familiar with TCL-OO and all of the TCLOO within msgcat came from others, sorry for that... Thank you all and take care, HaraldClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Am 14.07.24 um 15:43 schrieb Harald Oehlmann: > Am 14.07.2024 um 00:32 schrieb undroidwish: >> On 7/13/24 18:21, greg wrote: >>> 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). >> ... >>>> self may only be called from inside a method >> ... >>>> "uplevel 2 { self }" >>>> (procedure "PackageNamespaceGet" line 17) >>>> invoked from within >>>> "PackageNamespaceGet" >>>> (procedure "::msgcat::mc" line 2) >> ... >>> 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. >> ... >> >> My humble interpretation is that the problem lies in msgcat::mc >> fundamentally. Wrong assumptions over call context. Independent of >> Tcl versions 8 or 9. But I might be mislead still. It is worth a >> ticket anyways. > > Dear Mark, dear Christian, > > yes, both, msgcat and tooltip were recently changed. > > Did you use tklib 0.8 release and TCL/Tk 9.0b2 ? > > Those tickets are in both of them: > https://core.tcl-lang.org/tklib/info/3300362 > https://core.tcl-lang.org/tcl/tktview/e02798626dfbcd7b33db > > I tried your snippet with this and can reproduce the issue. > > Here is the TCL ticket: > https://core.tcl-lang.org/tcl/tktview/91b3a5bb14e6e8ae1d1c5349af12e08879ea152d > and here the TkLib ticket: > https://core.tcl-lang.org/tklib/tktview/6e85abae9e49281b3b1212e25082f73239f7ea9e > > I hope, we will find a solution. I am not familiar with TCL-OO and all > of the TCLOO within msgcat came from others, sorry for that... > > Thank you all and take care, > Harald > In msgcat.tcl (Tcl 9.0) This means I no longer get the error message. The namespace is being searched for at this point, and in my opinion self is not needed at all. proc ::msgcat::PackageNamespaceGet {} { set ns [uplevel 2 { namespace current }] if {![string match {::oo::*} $ns]} { # Not in object environment return $ns } # Check if we are within an object if {[info object isa object $ns]} { return [info object namespace $ns] } elseif {[info object isa class $ns]} { return [info object namespace $ns] } elseif {[info object isa metaclass $ns]} { return [info object namespace $ns] } elseif {[info object isa mixin $ns]} { return [info object namespace $ns] } elseif {[info object isa typeof $ns]} { return [info object namespace $ns] } else { # Not in an object or class environment return $ns } } GregorClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Am 14.07.2024 um 20:25 schrieb greg: > Am 14.07.24 um 15:43 schrieb Harald Oehlmann: >> Am 14.07.2024 um 00:32 schrieb undroidwish: >>> On 7/13/24 18:21, greg wrote: >>>> 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). >>> ... >>>>> self may only be called from inside a method >>> ... >>>>> "uplevel 2 { self }" >>>>> (procedure "PackageNamespaceGet" line 17) >>>>> invoked from within >>>>> "PackageNamespaceGet" >>>>> (procedure "::msgcat::mc" line 2) >>> ... >>>> 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. >>> ... >>> >>> My humble interpretation is that the problem lies in msgcat::mc >>> fundamentally. Wrong assumptions over call context. Independent of >>> Tcl versions 8 or 9. But I might be mislead still. It is worth a >>> ticket anyways. >> >> Dear Mark, dear Christian, >> >> yes, both, msgcat and tooltip were recently changed. >> >> Did you use tklib 0.8 release and TCL/Tk 9.0b2 ? >> >> Those tickets are in both of them: >> https://core.tcl-lang.org/tklib/info/3300362 >> https://core.tcl-lang.org/tcl/tktview/e02798626dfbcd7b33db >> >> I tried your snippet with this and can reproduce the issue. >> >> Here is the TCL ticket: >> https://core.tcl-lang.org/tcl/tktview/91b3a5bb14e6e8ae1d1c5349af12e08879ea152d >> and here the TkLib ticket: >> https://core.tcl-lang.org/tklib/tktview/6e85abae9e49281b3b1212e25082f73239f7ea9e >> >> I hope, we will find a solution. I am not familiar with TCL-OO and all >> of the TCLOO within msgcat came from others, sorry for that... >> >> Thank you all and take care, >> Harald >> > > In msgcat.tcl (Tcl 9.0) > > This means I no longer get the error message. > The namespace is being searched for at this point, and in my opinion > self is not needed at all. > > > proc ::msgcat::PackageNamespaceGet {} { > set ns [uplevel 2 { namespace current }] > > if {![string match {::oo::*} $ns]} { > # Not in object environment > return $ns > } > > # Check if we are within an object > if {[info object isa object $ns]} { > return [info object namespace $ns] > } elseif {[info object isa class $ns]} { > return [info object namespace $ns] > } elseif {[info object isa metaclass $ns]} { > return [info object namespace $ns] > } elseif {[info object isa mixin $ns]} { > return [info object namespace $ns] > } elseif {[info object isa typeof $ns]} { > return [info object namespace $ns] > } else { > # Not in an object or class environment > return $ns > } > } > > Gregor > Thanks a lot, Gregor. Your proposed solution is now in a branch referenced in the ticket. It would be great, if: - there would be a test case for the issue - the comment above the modification may be corrected. If I count the "if's" I get 7 cases and not 4. Sorry, work always results in additional work... Thanks for all, HaraldClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
On 7/14/24 21:01, Harald Oehlmann wrote: > Am 14.07.2024 um 20:25 schrieb greg: >> In msgcat.tcl (Tcl 9.0) >> >> This means I no longer get the error message. >> The namespace is being searched for at this point, and in my opinion >> self is not needed at all. >> >> >> proc ::msgcat::PackageNamespaceGet {} { >> set ns [uplevel 2 { namespace current }] >> >> if {![string match {::oo::*} $ns]} { >> # Not in object environment >> return $ns >> } >> >> # Check if we are within an object >> if {[info object isa object $ns]} { >> return [info object namespace $ns] >> } elseif {[info object isa class $ns]} { >> return [info object namespace $ns] >> } elseif {[info object isa metaclass $ns]} { >> return [info object namespace $ns] >> } elseif {[info object isa mixin $ns]} { >> return [info object namespace $ns] >> } elseif {[info object isa typeof $ns]} { >> return [info object namespace $ns] >> } else { >> # Not in an object or class environment >> return $ns >> } >> } >> >> Gregor >> > > Thanks a lot, Gregor. > > Your proposed solution is now in a branch referenced in the ticket. > It would be great, if: > - there would be a test case for the issue > - the comment above the modification may be corrected. If I count the > "if's" I get 7 cases and not 4. > ... Looks almost good, except that the tests for mixin and typeof require more context (one additional parameter). Thus they must be left out, i.e. ... # Check if we are within an object if {[info object isa object $ns]} { return [info object namespace $ns] } elseif {[info object isa class $ns]} { return [info object namespace $ns] } elseif {[info object isa metaclass $ns]} { return [info object namespace $ns] } # Not in an object or class environment return $ns ... My 0.02 currency units, ChristianClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
[snip] > Dear Mark, dear Christian, > > yes, both, msgcat and tooltip were recently changed. > > Did you use tklib 0.8 release and TCL/Tk 9.0b2 ? [snip] I used Tcl/Tk 9.0b2. I can't tell you which tklib I used since there is no overarching version number and the source file I downloaded doesn't have a version: Tk+Library+Source+Code-trunk.tar.gz However: $ wish9 % package require tooltip 1.8.2 Hope that helps.Click on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
For some reason the line breaks were removed, should have been: $ wish9 % package require tooltip 1.8.2Click on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Am 15.07.2024 um 08:48 schrieb Mark Summerfield: > For some reason the line breaks were removed, should have been: > > $ wish9 > > % package require tooltip > > 1.8.2 > Thanks, Marc, you may patch the msgcat by the solution by Greg or Christian and look, if this works for you. https://core.tcl-lang.org/tcl/info/6c6bee903dc57de0 It would also be great, to extend the test cases by your case, see here: https://core.tcl-lang.org/tcl/file?name=tests/msgcat.test&ci=tip Search for "test msgcat-15." to find all oo tests. I am personally totally in disagreement to support tcloo in msgcat. It always causes troubble.... But my personal view does not count, I am on your service.... Thanks for any help, HaraldClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Am 15.07.2024 um 06:22 schrieb undroidwish: > On 7/14/24 21:01, Harald Oehlmann wrote: >> Am 14.07.2024 um 20:25 schrieb greg: >>> In msgcat.tcl (Tcl 9.0) >>> >>> This means I no longer get the error message. >>> The namespace is being searched for at this point, and in my opinion >>> self is not needed at all. >>> >>> >>> proc ::msgcat::PackageNamespaceGet {} { >>> set ns [uplevel 2 { namespace current }] >>> >>> if {![string match {::oo::*} $ns]} { >>> # Not in object environment >>> return $ns >>> } >>> >>> # Check if we are within an object >>> if {[info object isa object $ns]} { >>> return [info object namespace $ns] >>> } elseif {[info object isa class $ns]} { >>> return [info object namespace $ns] >>> } elseif {[info object isa metaclass $ns]} { >>> return [info object namespace $ns] >>> } elseif {[info object isa mixin $ns]} { >>> return [info object namespace $ns] >>> } elseif {[info object isa typeof $ns]} { >>> return [info object namespace $ns] >>> } else { >>> # Not in an object or class environment >>> return $ns >>> } >>> } >>> >>> Gregor >>> >> >> Thanks a lot, Gregor. >> >> Your proposed solution is now in a branch referenced in the ticket. >> It would be great, if: >> - there would be a test case for the issue >> - the comment above the modification may be corrected. If I count the >> "if's" I get 7 cases and not 4. >> ... > > Looks almost good, except that the tests for mixin and typeof > require more context (one additional parameter). Thus they must > be left out, i.e. > > ... > # Check if we are within an object > if {[info object isa object $ns]} { > return [info object namespace $ns] > } elseif {[info object isa class $ns]} { > return [info object namespace $ns] > } elseif {[info object isa metaclass $ns]} { > return [info object namespace $ns] > } > # Not in an object or class environment > return $ns > ... > > My 0.02 currency units, > Christian I just ran the test suite and the result is quite fatal, sorry... https://core.tcl-lang.org/tcl/tktview/91b3a5bb14e6e8ae1d1c5349af12e08879ea152d Thanks for all, HaraldClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Hi Harald, On Mon, 15 Jul 2024 09:20:28 +0200, Harald Oehlmann wrote: [snip] > Thanks, Marc, > > you may patch the msgcat by the solution by Greg or Christian and look, > if this works for you. > https://core.tcl-lang.org/tcl/info/6c6bee903dc57de0 Sorry, I don't actually know how to use patch. > It would also be great, to extend the test cases by your case, see here: > > https://core.tcl-lang.org/tcl/file?name=tests/msgcat.test&ci=tip > > Search for "test msgcat-15." to find all oo tests. I'm only learning Tcl; I'm not familiar with msgcat (I wasn't knowingly using it!) nor with Tcl's test infrastructure. Nor do I know how to edit Tcl Source Code files (or even whether I can). I do have a login so I can see "msgcat.test at tip" but there's no Edit button for example. The only online code editing I've ever done is with github; I've never used fossil. Sorry! > I am personally totally in disagreement to support tcloo in msgcat. It > always causes troubble.... But my personal view does not count, I am on > your service.... > > Thanks for any help, > HaraldClick on article to view all threads in comp.lang.tcl
Re: Tklib's tooltip poss bug in method although fine in a function
Am 15.07.2024 um 12:43 schrieb Mark Summerfield: > Hi Harald, > > On Mon, 15 Jul 2024 09:20:28 +0200, Harald Oehlmann wrote: > [snip] >> Thanks, Marc, >> >> you may patch the msgcat by the solution by Greg or Christian and look, >> if this works for you. >> https://core.tcl-lang.org/tcl/info/6c6bee903dc57de0 > > Sorry, I don't actually know how to use patch. > >> It would also be great, to extend the test cases by your case, see here: >> >> https://core.tcl-lang.org/tcl/file?name=tests/msgcat.test&ci=tip >> >> Search for "test msgcat-15." to find all oo tests. > > I'm only learning Tcl; I'm not familiar with msgcat (I wasn't knowingly > using it!) nor with Tcl's test infrastructure. Nor do I know how to edit > Tcl Source Code files (or even whether I can). I do have a login so I can > see "msgcat.test at tip" but there's no Edit button for example. The only > online code editing I've ever done is with github; I've never used fossil. > > Sorry! > >> I am personally totally in disagreement to support tcloo in msgcat. It >> always causes troubble.... But my personal view does not count, I am on >> your service.... >> >> Thanks for any help, >> Harald > Hi Marc, well, your knowledge already superseeds my knowledge, so I was looking for some help. We had the TTT telco today and Donal Fellows said, that the proposal does not work and he will look about a better solution. To "patch" is to replace the file "msgcat-1.9.2.tm" by a modified file. Unfortunately, this is not so easy any more, as the tcl library is now within a zip file, as TCL9 puts all tcl files in a zip file. Thanks for all, HaraldClick on article to view all threads in comp.lang.tcl