When all you want is to run a Tk application

Summary

A complete noob's guide to running a Tcl or Tk program

See Also

Turn a tcl-tk script into an application
When all you want is to run a starkit

Description

Suppose someone has given you an application, saying, "Here; this is really cool. You should run it on your own computer and see." If just Tcl, or perhaps even Tcl and Tk were used to develop the application, and you're unfamiliar with the Tcl/Tk language, you might not know what's involved in "running it on your own computer." Here's an explanation of the minimum you need to know:

First determine whether you really need anything other than the application. Why? Because some application developers produce applications which 'stand alone' - they need nothing else to run. In that case, you really are set - just get the program, start it up, and off you go.

It's pretty easy for a Tcl developer to create things like that. For that matter, a more experienced developer is likely to have the ability to write his main code in C/C++/Java/etc. and then create Tcl within that environment.

However, if the code you want/need to run is one or more plain Tcl scripts, you will need to step through the following.

You likely don't have Tcl and Tk installed on your desktop. It won't take long to change that, though. For quickest results, you'll pick a "working directory" on your desktop, transfer a couple of (kinds of) files into it, and launch a process. At that point, the application will be running.

The two (kinds of) files are

  • the Tcl/Tk interpreter, and
  • the application, written in Tcl/Tk .

Your acquaintance has probably already given you the application source, likely named something like 'myprogram.tcl'. Make sure you have a copy of that in your working directory.

Now, copy in a working Tk interpreter. The easiest way to do this is by choosing the Tclkit binary appropriate to your operating system. You might, for example, retrieve the most recent Windows version at http://www.equi4.com/pub/tk/tclkit-win32.upx.exe .

At this point, you have a copy of two or more files in your working directory (or perhaps more; your acquaintance might package his work as a bundle of several distinct-but-related files). While at the "command prompt" specific to your operating system, move to the working directory, and enter the command

    tclkit myprogram.tcl

After a few seconds, the program will begin to execute. That's all.

myprogram.tcl is likely a "plaintext" source, so you can examine it with any common editor, and modify it as you choose. Once you've made a change, launch an instance of the updated application by repeating the command

tclkit myprogram.tcl

at the prompt.

CJL adds: A more Windows-y way of launching it would be to drag 'myprogram.tcl' and drop it on 'tclkit.exe'


Installing and launching Tk applications can be even simpler-- radically simpler, in fact, than for any other applications. Starkit presents advantages over Java's .jar-s and even C's fully-compiled-and-linked executables. The Starkit-ted TclWorld at [1 ] hints at the possibilities.

Hopefully, the person who wrote the application you are using has either kept their application to a single script file or has learned about starkits and is making use of them. If they will just read about how to build a starkit or even better a starpack, then they will be able to create an application that stands alone.


However, there is a gotcha here. The application may make use of extended functionality beyond what Tclkit supports. In that case, you have a bit more work to do. [add link to page that discusses how to tcl tcl apps which require add on extensions into starkits]

Several Tcl distributions are available as alternatives to Tclkit. "Getting Tcl/Tk" is a good guide to them.

Most people, in this case, turn to something like ActiveTcl. The reason - Activetcl's installation process is relatively painless, and the end result is a significantly larger amount of functionality for use within Tcl applications.

The last, and least attractive for a _user_ of a tcl application, would be that case that you find you have to build Tcl, Tk, and the pieces yourself. [add a link to pages to help with this alternative]