tksvg

Difference between version 2 and 5 - Previous - Next
**tksvg features SVG image for tcl8.6**

With [http://core.tcl-lang.org/tips/doc/trunk/tip/507.md%|%TIP507%|%], [svg]-support was added to tk8.7+.

To get the same support on tk 8.6, use package [https://github.com/auriocus/tksvg%|%tksvg%|%] by Auriocus.

**ChangeLog**

%|Version|Date|Text|%
&|0.1||Initial Version by Christian Werner|&
&|0.2||Ported to TCL 8.6 by Ariocous|&
&|0.3|2019-09-16|[https://core.tcl-lang.org/tips/doc/trunk/tip/545.md%|%TIP545%|%]: Added options "-scaletoheight" and "-scaletowidth". Added binary distribution|&

**Download**

The download is contained in the release area: [https://github.com/auriocus/tksvg/releases].

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.

**Distributions**

The following distributions contain TkSVG:

   *   [BAWT]

**Packages using tksvg**

The following packages use tksvg to scale images:
   *   [ttk::checkBbuttonT as toggle switch display]
   *   [awthemes] : Scalable awdark, awlight, winxpblue, black, breeze

**Compilation**

***Windows x86 (32 bit)***

tksvg 0.3 compilation succeeded using ms-vc6 with the following commands:

======none
vcvars.bat
setenv /RETAIL
cd win
nmake -f makefile.vc install TCLDIR=c:\test\tcl8.6.9 INSTALLDIR=c:\test\tknano
======

***Windows x64 (64 bit)***

tksvg 0.3 compilation succeeded using SDK2003SP1 with the following commands:

======none
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
======
***Linux (32 and 64 bit)***

======none
./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
======

**Usage for buttons**

Create an image with an svg image with the given height of 16 pixels:

======tcl
% 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:

======tcl
% 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.

**Text items in svg**

The used svg implementation "svgnano" does not support text items.
I paint my icons using [www.inkscape.org%|%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.

<<categories>> Graphics