clTcl

Home Installation Manual Examples Specification

Embed Tcl/Tk scripts in Common Lisp

Introduction

Tcl/Tk provides a powerful GUI library with a BSD-style open source license. It is a combination of the scripting language Tcl and the cross-platform widget toolkit Tk.

Package clTcl provides an interface to Tcl/Tk via Tcl scripts embedded into Common Lisp. Program your GUI with Tcl as embedded language. Scripts can be run by choosing one of the various Tcl/Tk interpreters. Deployment is possible for many systems.

This package gives easy access to the Tcl/Tk resources. The literal embedding of Tcl into Common Lisp makes it possible to paste any Tcl/Tk snippet into your code.

Hello World

The following fragment is the obligatory Hello World.

(cltcl:event-loop
  #TCL[package require Tk
       wm protocol . WM_DELETE_WINDOW {exit}
       label .message -text "Hello World!"
       pack .message])
      
Function event-loop starts the Tcl/Tk interpreter, executes the given script and starts listening for events to dispatch. It is typically used as application top loop.

The Tcl script is embedded with syntax #TCL[ ... ]. At the dots any literal Tcl script can occur.

Download

If you use asdf-install you can install clTcl as follows

(asdf-install:install 'cltcl)
      
Or you can download the gzipped tarball.

You also need a Tcl/Tk interpreter. If Wish is installed in /usr/bin/wish the clTcl runs out of the box. Otherwise you need to download one (no installation required!). See the installation page for instructions.

Documentation

Status

I have run it successfully with CLISP, SBCL, LispWorks, Clozure CL and CMU on GNU/Linux and with CLISP and LispWorks on Windows XP and Windows Vista. All combinations worked for the Wish interpreter and for a tclkit for Tcl/Tk 8.4 and Tcl/Tk 8.5. Other implementations and combinations should work without many problems.

On Windows XP the Tk commands tk_getOpenFile and tk_getSaveFile don't seem to work. (Alternatives ttk::getOpenFile and ttk::getSaveFile work fine)

Changes in this version:

Links

License

This software has an MIT license.

Contact

Written and maintained by Paul Griffioen.