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...
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.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,029 |
Nodes: | 10 (0 / 10) |
Uptime: | 150:30:27 |
Calls: | 13,333 |
Calls today: | 3 |
Files: | 186,574 |
D/L today: |
3,327 files (874M bytes) |
Messages: | 3,355,799 |