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)
... But I might be mislead still. It is worth a
ticket anyways.
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.
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.
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
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
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.
...
Dear Mark, dear Christian,[snip]
yes, both, msgcat and tooltip were recently changed.
Did you use tklib 0.8 release and TCL/Tk 9.0b2 ?
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
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,
Harald
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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 499 |
Nodes: | 16 (2 / 14) |
Uptime: | 47:10:15 |
Calls: | 9,834 |
Calls today: | 4 |
Files: | 13,764 |
Messages: | 6,193,833 |