contents
| 4.3 - Using packages in Starkits Using packages within a Starkit is only slightly different, and relies on the Tcl auto_path variable being set for us by the starkit::startup procedure. As an example, we’ll modify our hello.tcl script to use gButtons - the fancy Tk buttons package - which is itself packaged as a Starkit. There are two components we need to get from the gButtons Starkit - the gbutton and the autoscroll libraries. So, we download gButtons, unwrap it (using “sdx unwrap”) and copy both the lib/gbutton and lib/autoscroll packages to hello.vfs/lib. This gives us the new directory structure: hello.vfs Note that the gbutton directory includes both Tcl scripts and GIF images. A Starkit can contain scripts, images, data and (as we will see) binary extensions. Note also that we don’t include version numbers in the directory name of each library. This convention is quite deliberate, and the rationale is both aesthetic and practical:
Now we need a small modification to the hello.tcl script to use the new facilities. We’ll create a few buttons this time package provide app-hello 1.1 And now we wrap and use this as usual $ sdx wrap hello.kit One other point to note is that the Starkit is compressed - for example on Unix we see the following sizes $ du -bs hello.vfs hello.kit So, adding packages to a Starkit is simply a matter of placing them under the lib directory, and invoking them in the usual way. Binary extensions (i.e. platform specific shared libraries contained in packages) can be used under Starkits in the same way they can be used in any Tcl script. There is only one constraint - the extension must use the Tcl Stubs facility so that it can be dynamically loaded into the Tclkit interpreter. The main downside is that binary extensions make a Starkit platform specific. But with a little care, it is possible to construct a cross-platform Starkit containing binary extensions for multiple platforms. | see also | ||||