Tk Library Source Code

View Ticket
Login
Ticket UUID: 3300362
Title: Tooltip font, msgcat namespace
Type: RFE Version: None
Submitter: oehhar Created on: 2011-05-11 08:44:16
Subsystem: tklib :: tooltip Assigned To: aku
Priority: 3 Low Severity: Minor
Status: Closed Last Modified: 2024-05-24 16:30:19
Resolution: Fixed Closed By: oehhar
    Closed on: 2024-05-24 16:30:19
Description:
Leaving BWidget, I was looking to the tktooltip package. Here are two comments:

1) Tooltip font
Currently, the default font for labels is used as tooltip font.
This might not be the desired font.
 Since Tk8.5, there is the special font "TkTooltipFont" containing the current tooltip font which might be used.
Possible code from BWidget: 
    if {$::tcl_version >= 8.5} {
        set fontdefault TkTooltipFont
    } elseif {$Widget::_aqua} {
        set fontdefault {helvetica 11}
    } else {
        set fontdefault {helvetica 8}
    }
   label -font $fontdefault

2) msgcat namespace
IMHO, the use of msgcat within tooltips is half baken:
- the namespace where msgcat::mc is called should be the namespace of the caller and not ::tooltip
- there are no parameters allowed to" msgcat::mc"

Suggestion:
- save the caller namespace on tooltip creation for a later msgcat call
- add a "--" option to the arguments to stop argument parsing
- Allow to have multiple arguments after the message key.
  Save it as list and pass it to msgcat as arguments.

Possible msgcat call with namespace and arguments
  namespace eval $ns [concat ::msgcat::mc $lkey]

I would volonter to submit a patch for the two issues if this sounds reasonable

- Harald
User Comments: oehhar added on 2024-05-24 16:30:19:

Commit [c97cae5b0c] addds the options *-msgargs* and *-infoargs*. The ticket proposal was not taken to eventually allow later to not require "" around the message or other extensions. Anyway, there were two of them needed, one for msg, one for -info.

Here is a demonstrator script:

package require tooltip
msgcat::mcset "de" testMsg "This is not shown"
namespace eval test {
	pack [ttk::entry .e]
	msgcat::mcset "de" testMsg "Message with two variables: %s, %s"
	msgcat::mcset "de" testInfo "Info with two variables: %s, %s"
	::tooltip::tooltip .e -msgargs {"Var 1" "Var 2" "Var 3"} testMsg
}
namespace eval test2 {
	pack [ttk::entry .e2]
	::tooltip::tooltip .e2 -namespace ::test\
			 -msgargs {"Var 1" "Var 2" "Var 3"}\
			 -infoargs {"Info 1" "Info 2" "Info 3"}\
			 -info testInfo\
			 testMsg
}

I am running out of time today and may resume in one week. The info part does not fill the whole box showing a yellow triangle in the corner. Anyway, I would prefer yellow background instead of the grey as BWidget ;-).

Thanks for all.

Ticket closed.

Take care, Harald


oehhar added on 2024-05-24 16:11:29:

With commit [b145a5c24f], the namespace handling is handled for msgcat.

Here is a test script:

package require tooltip
msgcat::mcset "de" testMsg "This is an outer test message"
namespace eval test {
	pack [ttk::entry .e]
	msgcat::mcset "de" testMsg "This is a test message"
	::tooltip::tooltip .e testMsg
}
namespace eval test2 {
	pack [ttk::entry .e2]
	::tooltip::tooltip .e2 -namespace ::test testMsg
}

Without the patch, the outer message is shhown. Now, the message within the namespace is shown.