Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Set font on ctext widget

瀏覽次數:36 次
跳到第一則未讀訊息

Alexandru

未讀,
2018年12月9日 下午2:49:442018/12/9
收件者:
Hi,

I use next procedure to set the font on all "text" and "ctext" widgets.
Works for "text". Fails for "ctext".
I did add the .t to the widget path of ctext widgets.

proc TextSetFont {w {fontname "Lucida Sans Typewriter"}} {
foreach tagname [$w tag names] {
$w tag configure $tagname -font [list -family $fontname]
}
}

Any idea how to set font on ctext?

Thanks!
Alexandru

briang

未讀,
2018年12月9日 下午4:03:362018/12/9
收件者:
The post does not indicate what the results are from the code above.

I'm not entirely sure how much the ctext widget manages the underlying text widget with respect to fonts, it's possible the ctext wrapper is blocking the change for some reason. If that is the case, then you may need to use the ctext specific configuring commands (e.g. ctext::addHighlightClass) to set the desired font.

Generally speaking about the text widget:

The widget font should be used when setting the font across all text ( $w configure -font $font ).

If a tag has a font value that is empty ( [$w tag cget -font] eq {} ), it should not be blindly changed unless it is intentional to have a different font from the default widget font.

-Brian

Alexandru

未讀,
2018年12月9日 下午4:12:482018/12/9
收件者:
Thanks for the tipp. The issue can be solved by directly setting the font on the widget, not only on the tags.

If $w is the path of the ctext widget, then you can use:

$w.t configure -font [list -family "Lucida Sans Typewriter"]

briang

未讀,
2018年12月9日 晚上7:24:482018/12/9
收件者:
Interesting. [$w configure] is supposed to forward the configure to the .t subwidget, so it's not clear why this workaround is necessary. Seems like a bug to me.

-Brian
0 則新訊息