[Pkg-tcltk-devel] Bug#516178: Choosing between Tk library versions

Konstantin Khomoutov flatworm at users.sourceforge.net
Fri Feb 20 10:11:27 UTC 2009


First of all, on my Lenny system I have

$ head -n 3 `which gitk`
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec /usr/bin/wish8.5 "$0" -- "$@"

with stock gitk 1:1.5.6.5-3, which means it does forcibly
use wish8.5 and thus Tk8.5 and Xft/fontconfig.

Now some info on Tk versioning.

Tcl/Tk applications, including gitk, in most cases use
the so-called "Tcl windowing shell" (wish), which is a Tcl shell
(tclsh) but with preloaded Tk package.
So, to run a Tcl/Tk application you usually make a call like

$ /usr/bin/wish /path/to/tcl-tk-app.tcl

or use that trick based on different ideas about
parsing backslash+newline sequence in comments between the Unix
shell and Tcl [1] (which is seemingly being used in gitk).
Gitk actually gets this wrong, but more on this later.

The interesting part is that several versions of Tcl/Tk runtime
can coexist on the same system without affecting each other.
Lenny has 8.3 (legacy), 8.4 (old) and 8.5 (current) versions
plus 8.6b1 in experimental (personally I have 8.4, 8.5 and 8.6b1
installed for development reasons).

Both Tcl and Tk packages, for each runtime version, provide
shells named accordingly to that version, e.g. tclsh8.4,
wish8.4, tclsh8.5, wish8.5 etc.
And both Tcl and Tk packages support alternatives by
providing canonical symlinks from /usr/bin/tclsh and
/usr/bin/wish to the appropriate binary with "versioned" name.
So the user can pick the default versions of Tcl and Tcl/Tk
shells by executing

# update-alternatives --config tclsh
# update-alternatives --config wish

Gitk, therefore, unless it depends on some 8.5 features, should
better be using just /usr/bin/wish and let the user choose
whatever version of Tcl/Tk they prefer. Or better yet -- use
a wrapper shell script like

#! /bin/sh
exec /usr/bin/wish /usr/share/gitk/gitk.tcl -name Gitk

And a word on fonts in Tk 8.4. While the shift was definitely
made to Xft/fontconfig, and I'm not about discussing the pros
and cons of this, the "ugly fonts syndrome" of non-Xft-enabled
versions of Tk is just a misconfiguration of the system.
All you have to do is to install some pretty bitmap font (say,
Terminus), then do

$ cat >~/.Xresources
*font: -xos4-terminus-medium-r-*-*-*-*-*-*-*-*-iso10646-*
^D
$ xrdb -merge ~/.Xresources

This "old-school" setup is often overlooked because the desktop
has been taken over by Gtk- and Qt-based systems which not only
use Xft/fontconfig exclusively but also build their own layers
of font customizations on top of it.

1. http://wiki.tcl.tk/812






More information about the Pkg-tcltk-devel mailing list