LJ Archive

Graphical Toolkits for Linux Programs

Patrick Lambert

Issue #64, August 1999

A brief look at several popular toolkits available for Linux.

Linux is now a reality—it is no longer just a hacker tool or a toy for students. As such, it needs the power of console programs ported to the graphical world. People want easy-to-use desktops with good-looking programs. This is why many programmers now turn to graphical toolkits.

While many toolkits are available, they all share some basic features. Since programming languages do not include built-in functions to make graphical widgets, you must use add-ons. Graphical toolkits are actually libraries which add functions to a programming language, allowing you to integrate a graphical interface to your program.

The main differences found between various toolkits are ease of use, graphical appeal, cross-platform portability and language. If, for example, you are experienced in the Tcl scripting language, you will probably want to use the Tk graphical toolkit. If you like Perl, you may pick Perl/GTK.

GTK, the Gimp Toolkit

The GTK toolkit seems to be one of the most popular. It is modern and easy to use. That library was made in C as the base for the GIMP, an image manipulation program. Now it is used by programmers around the world for all kinds of applications, including the GNOME desktop environment. The graphical interface looks clean and much like interfaces on other operating systems.

GTK is a good toolkit for writing applications in C, since it is a C library. The GTK toolkit is built on top of the GDK library, which is on top of GLIB. All three provide unique functions to programmers. Available functions include memory handling, graphical components and widgets. GNOME also has its own extensions. GTK and GNOME are freely available software products.

The GTK library is available at http://www.gtk.org/. A tutorial on GTK is available at http://www.gtk.org/tutorial1.2/.

QT from Troll Tech

The QT toolkit was created by Troll Tech, a software company in Norway, and is used in the KDE desktop environment. It is written in C++ and used by programmers worldwide. The QT library began as a commercial product, but now Troll Tech has released a free version under an open license. Similar to GTK, it has the same kind of widgets, including labels, entry boxes and text fields. QT would be a good choice if you write applications in C++. The QT library is cross-platform, and the graphical interface of programs using it will compile without changes in both UNIX and Microsoft Windows.

The QT widgets look very much like GTK's widgets, as well as those of other operating systems.

The QT library is available from http://www.troll.no/. A tutorial on QT is available from www.troll.no/qt/tutorial.html.

wxWindows

wxWindows (w for Windows, x for X Window System) was created at the University of Edinburgh as a cross-platform toolkit. wxWindows is a C++ framework that allows you to write graphical applications. You can write your code once, then compile it under one of the many ports of the library. It currently runs under Microsoft Windows, Macintosh OS, Motif under UNIX and GTK. There is one library per platform, all providing a common API.

wxWindows is a free product, under a license similar to the L-GPL. Using it, you can write both commercial and free products.

wxWindows is available from http://www.wxwindows.org/. A tutorial is available from web.ukonline.co.uk/julian.smart/wxwin/hello.htm.

GraphApp, Platform-Independent GUI Programming in C

This toolkit is a favorite of mine. GraphApp is a C library that allows you to write simple graphical applications in C. It is a cross-platform toolkit, and will work on the Macintosh OS, Microsoft Windows, Motif under UNIX and Athena. GraphApp supports a more limited number of widgets, but is truly easy to learn. You can learn how to make graphical applications in less than an hour.

A nice thing about GraphApp is that it compiles as a small static library. This means you can compile your programs with the library linked in them without increasing the size of the binary much, and the user will be able to run it without installing the toolkit.

The GraphApp toolkit is available at http://www.cs.usyd.edu.au/~loki/graphapp/. A tutorial for GraphApp is available at http://www.cs.usyd.edu.au/~loki/graphapp/tutorial/.

Motif, the Standard

Motif has been the standard graphical toolkit for years on UNIX and other platforms. It is a commercial standard and has its own look. Motif is the base for the popular CDE desktop environment, also a standard on many commercial UNIX systems.

On Linux and other open systems, developers have made a free Motif clone called LessTif. LessTif is source compatible with Motif and available under the L-GPL. Motif and LessTif offer cross-platform compatibility among UNIX systems. While Motif code will not work on most non-UNIX systems, many commercial UNIX systems come with Motif libraries. Also, Motif has the advantage of having passed the test of time.

LessTif is available from http://www.lesstif.org/. LessTif documentation is available from www.lesstif.org/Lessdox/lesstif.html.

While I have not covered all existing toolkits, I have briefly covered the most popular ones. Most programmers are concerned about two things: graphical look and portability. GTK and QT are probably used the most in the Linux world, mainly because of the GNOME and KDE desktop environments. Users want a desktop that will provide all utilities using the same graphical look. I use both GTK and GraphApp, but this is a personal choice which every programmer must make for himself.

The GNOME web page is at http://www.gnome.org/. The KDE web page is at http://www.kde.org/.

Patrick Lambert is currently a student in Computer Science at the University of Montréal. He has been using various UNIX and Linux systems for 5 years, doing software development and systems administration. He can be reached at drow@darkelf.net.

LJ Archive