The initial value of tk_library is set when Tk is added to an interpreter; this is done by searching several different directories until one is found that contains an appropriate Tk startup script. If the TK_LIBRARY environment variable exists, then the directory it names is checked first. If TK_LIBRARY is not set or does not refer to an appropriate directory, then Tk checks several other directories based on a compiled-in default location, the location of the Tcl library directory, the location of the binary containing the application, and the current working directory.
The variable can be modified by an application to switch to a different library.
This value is normally the same as the result of “package require tk”.
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.
On the windowing systems win32 and aqua the scaling percentage is computed by rounding [tk scaling] * 75 to the nearest multiple of 25 that is at least 100. (On aqua the result is always 100, and the desktop engine automatically scales everything as needed.) On x11, deriving the scaling percentage from [tk scaling] is done as fallback method only, because the implementation of display scaling is highly dependent on the desktop environment and it mostly manipulates system resources that are resident outside of Xlib, which Tk is based on. Moreover, for technical reasons, the value assigned to the variable tk::scalingPct can be different from the one selected in the system settings (e.g., 200 rather than 125, 150, or 175 when running GNOME on Xorg or the Cinnamon desktop). On x11 the scaling percentage is computed mostly (but not exclusively) from the value of the X resource Xft.dpi, and, as an additional step, Tk synchronizes the scaling factor used to convert between physical units and pixels with the scaling percentage, with the aid of the tk scaling command.
[list svg -scale [expr {$tk::scalingPct / 100.0}]]
Typical values are {svg -scale 1.0}, {svg -scale 1.25}, {svg -scale 2.0}, etc. It is recommended to pass the value of this variable to the commands image create photo, imageName configure, imageName put, and imageName read as the value of their -format option when creating or manipulating SVG images, to make sure that their sizes will correspond to the display's DPI scaling level.
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.