A simple single file hello.tcl Starkit under the title Build Your First Starkit. This tutorial takes you beyond a simple single file hello.tcl Starkit into a mult-file hello.tcl Starkit. The code presented here was developed quickly after chatting in the Tkchat application.
First, this example is going to show how to start without using the qwrap method. It's quite easy. Create the following directory structure:
Hello.vfs/ Hello.vfs/lib/
Hello.vfs is where our code will go and Hello.vfs/lib is where any extensions may be placed.
Create the main.tcl file under the Hello.vfs directory, let's get starkit up and running:
package require starkit starkit::startup # Load our main source into the starkit set dir [file dirname [info script]] source [file join $dir hello.tcl]
Now we create our application in simple Tcl/Tk. No need to deal with or know about Starkit from here on out. We do, however, have to take special consideration during the sourcing of other files.
Create the hello.tcl file under the Hello.vfs directory:
package require Tk # Get the current scripts directory set dir [file dirname [info script]]; # Source in the supporting file with the current scripts # directory as it's base source [file join $dir funcs.tcl] # The example code button .hello -text "Say Hello" -command { sayHello "World" } pack .hello -padx 5 -pady 5 -expand 1 -fill both
Create the "sourced" file, funcs.tcl also in the Hello.vfs directory:
# Supporting functions proc sayHello {toWho} { tk_messageBox -icon info -type ok -title "Saying Hello" -message "Hello, $toWho" }
Now you can wrap it with the sdx command:
sdx wrap Hello.kit
and run your new multi-file Starkit:
tclkit Hello.kit
Now, the nice thing about this method is that you can also develop/test/run/deploy as a standard Tcl/Tk app as well.
tclsh Hello.vfs/hello.tcl
Will run your app with out problems under tclsh. In the end my directory entire project structure looks like:
HelloProject/ HelloProject/Hello.vfs/ HelloProject/Hello.vfs/main.tcl HelloProject/Hello.vfs/hello.tcl HelloProject/Hello.vfs/funcs.tcl HelloProject/Hello.vfs/lib
At a later date (once I have it all working) I'll add in my Makefile that gives me simple commands like:
make kit make exe make run-tcl make run-kit make run-exe
This page was created by a novice, so your milage may vary. Please, comment on this if you have further instructions or better ways of doing it.