Ktk: Enabling the KDE Revolution!

Ktk, version 0.3.1
Released 23rd February 1999
Ktk is a library of procedures designed to allow Tcl/Tk
applications (using the Tix extension)
to look like (and mostly to behave like) the native KDE ones.
This page describes version 0.3.1.
You can download it from the following places;
Contents
About This Package
Scripting languages for Qt (the toolkit used by KDE) are available.
Bindings for Python and Perl are around, but if you like the clean
style of Tcl/Tk then they're not for you!
This web page gives details of my Tcl/Tk library (called Ktk)
which allows tixwish programs to come close to the native KDE look
and feel.
Ktk
is designed to be used with the Tix extension for wish. There are
several reasons why I chose Tix--support for xpm and several
new ``mega widgets'' being the most significant.
It currently looks as though work on Tix has stopped. This is a great
pity and could become a problem as newer versions of Tcl and Tk are
developed. Recently, while developing the file select window, I've found
a number of annoyances (I'd call them bugs) with Tix which has taken a lot
of effort to work around, so the time when Tix may be dropped is closer.
It should be fairly easy
to retro-fit Ktk to an existing wish application in order to
``K-ise'' it, though modifications may still be necessary in order to
conform to the
KDE style guide.
KDE Applications: differences with Tcl/Tk
There are several areas where standard Tcl/Tk (actually the Tk toolkit) is
different from KDE applications (actually the Qt toolkit).
Drag and Drop
Tk does not support the Qt drag-and-drop mechanism. This is a crucial area
that requires more work. Any volunteers?
I note that with Qt release 2.0 KDE will move to use XDND. I also note that
GNOME is using XDND, so the value of having XDND support in Tcl/Tk is
greater than ever.
In a later version I plan to add very crude drag-and-drop support which
would allow an open application to receive ``events'' when objects are
dropped over desktop icons.
Colours and Fonts
KDE applications can be re-coloured and the default font changed via
the control panel. KDE applications which are open are updated
dynamically. Tk applications can read the current colour scheme and
default font (stored in $HOME/.kderc) but are unable to
dynamically update themselves.
Ktk provides a procedure which initialises the
Tk option database to use the currently selected colour scheme and
font. If the user changes these settings in mid-session, Tk
applications will not use the new values until re-started.
Session Management
KDE applications which are running when you logout are re-started when
you next login. They even know what they were doing and where on the
desktop they were. A very primitive form of session management is
possible using the -rcfile and -saveposition
options with the
Kinit procedure.
Dialogues
Qt uses different images for the dialogues.
Ktk provides a procedure which mimics the KDE/Qt dialogue.
Menubars and Toolbars
Qt has a small button at the left-end of all menu and tool bars. This allows
the bar to re-positioned in the main application's window, including making
it float (a bit like the tear-off feature of Tk's menus).
Ktk provides a
utilitybar widget which could allow the
implementation of moving bars about.
Buttons displaying images (KDE Tool bars)
Buttons which display images in Qt normally display pixmaps. This
is possible with the Tix extension.
Standard Tk cannot handle pixmaps; only bitmaps (xbm) or
full-colour ``photo'' images.
The Qt image button is flat until the mouse enters the widget, when it
becomes raised. A tool-tip is posted if the mouse remains over the
widget for longer than about 1 second.
Ktk provides the
toolbutton widget which mimics the Qt tool button.
Advanced widgets
Tk lacks some of the more advanced widgets such as the tabbed dialog box, the
combobox and the labelled-frame. All of these (and many more) are available
in the Tix extension. Not only that, but they look very like their Qt
counterparts!
Tear-off Menus
Tk supports tear-off menus but KDE/Qt does not. Tear-off menus are
disabled by Ktk. Because of this change, the index position of
menu items (they are reduced by 1) some scripts may break.
Some examples
Here are some screen shots of some wish applications which demonstrate the
capabilities of version 0.3 Ktk.
HelpU is a man-page reader modelled along the lines of the excellent
``tkman'' program. This is how it used to look:
...and kman is the result after K-ising it with Ktk-0.3;
kexample
is included in the distribution tarfile.
It is a mock-up of a typical KDE application with menu, toolbar
and combobox. The screen shot shows how similar it looks to a
KDE/Qt application, but using it shows even more similarities;
the toolbar buttons have identical behaviour including tool tips and
the pop-up dialogues look just like KDE/Qt.
kexample demonstrates the following features;
- the `cut' button (fifth one from the left) toggles the state of the
idea button (the first one).
- the tooltip for the `cut' button changes according to the state of the
idea button
- the exit toolbutton includes text
- the home button (the fourth from the left) changes the text on the
exit button
- the second and third buttons are created disabled (note the sunken
shading)
- the options, displayed by the Option menu, are saved when the program
terminates
- clicking Button3 over the menubar's extreme left control area gives
a popup menu
- using the file select window (from the File menu), the chosen file name
is inserted into the combobox
Installing Ktk
You will require the Tix extension for Tcl/Tk. Version 0.3.1 of
Ktk has been tested with Tix 4.1.0 together with tk 4.2
and tcl 7.6. I see no reason why it shouldn't work when Tix is
compiled with later versions of Tcl and Tk, e.g. 8.
Having downloaded the library, installation is very simple:
- place K.tk in a convenient directory, such as
/usr/local/lib. To make life easy, install it in the same
directory as other Tk libraries
- (re-)create the tclIndex file by running the tixindex
program (which is part of the Tix installation) in the installation
directory using the command
tixindex *.tk
- in your wish application which wants to use Ktk, add the
pathname of the install-directory to the special Tcl list
auto_path using
lappend auto_path install-pathname
You must also install the files for the help pages for the kfileselect
window. Typically this is how;
- create the directory "kfileselect" under your
$KDEDIR/share/doc/HTML/default directory. You may need to be "root"
to do this
- copy all the files from the distribution's kfileselect.help directory
to the newly created "kfileselect" directory
- on a multi-user setup, make sure all your users can access the files by
giving them general read permission.
Andrew F. Lack
Last Updated: 7th December 1998
You were reader
.