Version 8 of Build Your First Starkit

Updated 2004-03-09 18:18:44

starkits rely on a feature of Tcl/Tk 8.4 called the Virtual File System (VFS). Through the magic of VFS, a starkit contains an entire directory structure, including scripts, libraries, and even data files. The trick is to set up a structure which works in unpacked form while coding and testing, and which can later be assembled into an equivalent packaged starkit. Fortunately, all the infrastructure and tools are provided for you, and the whole process is very easy.


STEP 1: Get Tclkit and sdx

The Unix, Linux and Mac binaries need to be unpacked, renamed, and made runnable:

    gzip -d tclkit-*.gz
    mv tclkit-* tclkit
    chmod +x tclkit

SDX is the Starkit Developer eXtension. It is a starkit containing tools for manipulating Starkits and Starpacks. Get sdx.kit from http://www.equi4.com/pub/sk/sdx.kit . Since it's a starkit, you can try it with "tclkit sdx.kit".

If this command responds with the error "can't find package starkit" then add read permissions to your tclkit binary.

You now have STARKIT TECHNOLOGY!!


STEP 2: Wrap Your Application

You can easily wrap any single file Tcl application. For this example, create a file "hello.tcl" with the following two lines of text:

        package require Tk
        pack [button .b -text "Hello World!" -command bell]

use the "qwrap" option to quickly turn a single script into a starkit:

        tclkit sdx.kit qwrap hello.tcl

The result is a file called hello.kit. On Windows, SDX will also create a file hello.bat. Type "hello" on Windows, or "./hello.kit" on Unix. You'll see a window with button which beeps when clicked


STEP 3: Unwrap Your Application

Your wrapped application contains an entire virtual file system. In this case, we have just one script file, but even this simple application has all the virtual file system support you would get with a complex applcation. To see the contents of your starkit, unwrap it like this.

        tclkit sdx.kit unwrap hello.kit

This creates a copy of hello.kit's virtual file system in a directory named "hello.vfs/". You will find the startup script at "hello.vfs/main.tcl", and your hello.tcl script has been converted into a package in hello.vfs/lib/app-hello/.


STEP 4: Make Changes

One of the benefits of starkit applications is that they run exactly the same way wrapped or unwrapped. Both these commands will execute your application, and your application will execute identically.

    tclkit hello.kit
    tclkit hello.vfs/main.tcl

So you can continue application development in the unwrapped starkit. Add scripts, data files, or packages under hello.vfrs/lib/, and they will all be found by your application. Work on the unwrapped application until it's just right.


STEP 5: Wrap It Up

When you are ready to create an updated starkit, do:

        tclkit sdx.kit wrap hello.kit

This takes hello.vfs/ as input, and overwrites hello.kit as before, creating an application that can be run with "hello" (Windows) or "./hello.kit" (Unix)

Notice that your application development structure (hello.vfs/) is exactly the same as the starkit. And your starkit will run on any plaform with a Tclkit binary runtime because in this case, the application makes use of only scripts in the starkit and packages in tclkit.


Category Tclkit