With TIP507 , svg-support was added to tk8.7+.
To get the same support on tk 8.6, use package tksvg by Auriocus.
Version | Date | Text |
---|---|---|
0.1 | Initial Version by Christian Werner | |
0.2 | Ported to TCL 8.6 by Ariocous | |
0.3 | 2019-09-16 | TIP545 : Added options "-scaletoheight" and "-scaletowidth". Added binary distribution |
The download is contained in the release area: [L1 ].
It contains currently the source and binaries for Linux (64 bit), Mac and Windows (32 and 64 bit).
Note: Windows binaries contained a bug (function fabsf was mapped to abs, not fabs), which was corrected shortly after the release. The released binaries contain the fixed version.
The following distributions contain TkSVG:
The following packages use tksvg to scale images:
tksvg 0.3 compilation succeeded using ms-vc6 with the following commands:
vcvars.bat setenv /RETAIL cd win nmake -f makefile.vc install TCLDIR=c:\test\tcl8.6.9 INSTALLDIR=c:\test\tknano
tksvg 0.3 compilation succeeded using SDK2003SP1 with the following commands:
setenv /XP64 /RETAIL cd win nmake -f makefile.vc TCLDIR=c:\test\tcl_x64_build\tcl8.6.9 TKDIR=c:\test\tcl_x64_build\tk8.6.9 nmake -f makefile.vc install TCLDIR=c:\test\tcl_x64_build\tcl8.6.9 TKDIR=c:\test\tcl_x64_build\tk8.6.9 INSTALLDIR=c:\test\tcl_x64_build\tksvg_64
./configure --with-tcl=/home/oehhar/test/tcl8.6.9 --with-tk=/home/oehhar/test/tk8.6.9 --exec-prefix=/home/oehhar/test/tksvg0.3 make
Create an image with an svg image with the given height of 16 pixels:
% image create photo i1 -file c:/myimage/test.svg -format {svg -scaletoheight 16} % pack [button .b1 -image i1]
Now the button is scaled to 20 pixels in runtime:
% i1 configure -format {svg -scaletoheight 20}
The button image is scaled.
Attention: the image file must be available, as it is read from disk again. So, if you remove the file c:/myimage/test.svg, the command will fail.
If this is an issue, load the image first into a variable and pass the data with the "-data" option to the image creation command.
The used svg implementation "svgnano" does not support text items. I paint my icons using InkScape as follows: To display text, first use the text tool to print the text. Then go to the path menu and select "transform object to path" with the shortcut "Shift-Control-C". After save, the text is visible within tclnano.