Version 21 of Build Your First Starkit

Updated 2005-07-22 02:40:09

Purpose: to guide a new user through the steps of building a starkit.

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

On UNIX/Linux/MacOS X, be certain that tclkit is in a directory that is in your $PATH.

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 run it with the command

    tclkit sdx.kit

If this command responds with the error "can't find package starkit" then you need to add read permissions to your tclkit binary. On UNIX/Linux type systems, this would be via:

    chmod u+r tclkit

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 named "hello.tcl" and use the following two lines of text as its contents:

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

Use sdx's "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.vfs/lib/, and they will all be found by your application. Work on the unwrapped application until it's just right.


AT[L1 ] I would mention here that running it as a starkit is different than running it as a starpack because the path is different...this caused me confusion the first time I built a star(pack|kit). LV AT, what do you mean when you say because the path is different?


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.


2005-7-21 JM When trying the last step (update the kit), I am getting the following error: "Couldnt open Hello.kit", the file is not set to "read only" and it exists. I also tried the -writable (it also appears as -writeable in some places in this wiki) and the error still showing up. (I am using Windows XP)

LV I don't have a Windows system handy. Did you try typing the name as lower case? It may not make a difference, but I notice the example shows a lower case "hello"...

RLH - If I remember I will post the contents of a make.bat file that I use to automate the process for me.

JM I tried all these instructions again in a different machine (same OS: WXP) and I am geting same error, being a little bit more verbose here, some more information on the erro message is:

 "couldn't open "hello.kit": invalid argument while executing "open $name w"
 (procedure "writefile" line 2)..."

I typed all the letters lower case. I did it again just to double check. same error...


Category Tclkit | Category Tutorial