Re: Custom scaling factor for Tk 9 widgets

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Custom scaling factor for Tk 9 widgets
De : csaba.nemethi (at) *nospam* t-online.de (nemethi)
Groupes : comp.lang.tcl
Date : 24. Mar 2025, 13:06:11
Autres entêtes
Message-ID : <vrrhrj$asu3$1@tota-refugium.de>
References : 1
User-Agent : Mozilla Thunderbird
Am 24.03.25 um 12:07 schrieb Harald Oehlmann:
Dear Tk team, dear Csaba,
 thanks for making Tk scalable.
 Please allow me to ask a dump question.
 My applications do use a custom scaling factor based on character size.
 For the AWThemes, there was the possibility of a scaling factor and I set it before activating the theme. This scales all elements like checkboxes etc.
 Here is a snippet with a font size in points in Config(FontSize): example: 32
 package require awthemes
# >> Do AWDark scaling
# >> Get element scaling factor from current font size
set dFontSpec [font actual TkDefaultFont]
dict set dFontSpec -size $Config(FontSize)
set ScaleCur [expr {
     double([font metrics $dFontSpec -ascent])
     / [font metrics TkDefaultFont -ascent]}]
::themeutils::setThemeColors AWDark scale.factor $ScaleCur
package require AWDark
ttk::style theme use AWDark
 Is it possible to do something like this with plain Tk 9.0 ?
 Is it even possible to change the scaling factor on runtime ?
(this is not possible with the AWThemes) ?
 Thanks for any answer,
Harald
 P.S.: and it is so sad, that Brad Lanam is gone. With Tk 9, the AWThemes would be even greater...
Tk sets the variables tk::scalingPct and tk::svgFmt at initialization time.  The reference manual states, among others, the following:
tk::scalingPct
     Note that any access to this variable is supposed  to  be
     strictly  read-only!  Note also that whenever the scaling
     factor used to convert between physical units and  pixels
     is  changed  via  tk  scaling,  the value of the variable
     tk::scalingPct is automatically updated.
tk::svgFmt
     Note  that  any access to this variable is supposed to be
     strictly read-only!  Note also that whenever the  scaling
     factor  used to convert between physical units and pixels
     is changed via tk scaling,  the  value  of  the  variable
     tk::svgFmt is automatically updated.
That is, on runtime you can invoke "tk scaling", which will not only change tk's scaling factor used to convert between physical units and pixels, but will also automatically update the variables tk::scalingPct and tk::svgFmt.
For example, if initially "tk scaling" returns 1.33 (as is the case on an unscaled screen) and you invoke
     tk scaling 2.66
then the value of tk::scalingPct will become 200 and that of tk::svgFmt will become "svg -scale 2.0".  And the checkbuttons of all builtin themes will become twice as large as without the above command invocation.
--
Csaba Nemethi  https://www.nemethi.de  mailto:csaba.nemethi@t-online.de

Date Sujet#  Auteur
24 Mar 25 * Custom scaling factor for Tk 9 widgets3Harald Oehlmann
24 Mar 25 `* Re: Custom scaling factor for Tk 9 widgets2nemethi
24 Mar 25  `- Re: Custom scaling factor for Tk 9 widgets1Harald Oehlmann

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal