Wrap: Standalone executables with Tcl/Tk8.2.1 |
|
| references since December 16, 2000 |
Did you ever wondered why Tcl/Tk standalone executables need to be so big? When you use tcl2c, Freewrap or Mktclapp, generally the resulting executables are larger than 1 MByte. Here is the proof that they can be made much smaller: The Wrap 0.3 binary distribution contains two fully functionally standalone executables with the Memchan and Metakit extensions and everything to create your own standalone executables. Still everything together fits on a single floppy:
The Wrap binary distribution has the following features:
The trick is that the standalone executables in reality are zip-files as well. Thus they can be handled with the standard zip-utility.. The supplied "zip.exe" in reality is nothing more than zip 2.2 ported to Windows (using gcc-2.95, mingw variant). The most important part of Wrap is the handling of zip-entries; being able to uncompress them and handle them on-the-fly in various ways.
Now - as a demonstration - let's create our first standalone executable. Assume we have a "hello.tcl" script, which we want to wrap up in an executable
# hello.tcl button .b -text button -command exit pack .b
The procedure to do this from the DOS command line is:
> copy wish82s.exe hello.exe > zip -9 -A hello.exe hello.tcl
That's all. The "-9" option (recommended) selects maximum compression and the "-A" option (obligatory) corrects for the non-standard zip-header. Now assume you want to add a GIF-file to the button, which should be wrapped in the executable as well:
# hello.tcl set f [wrap::open hello.gif] fconfigure $f -translation binary set hello [read $f]; close $f [image create photo hello] put $hello button .b -image hello -command exit pack .b
You can wrap both the script and the GIF-file in the executable by:
> copy wish82s.exe hello.exe > zip -9 -A hello.exe hello.tcl hello.gif
See how simple it really is: If you want to read data from the executable,
just use wrap::open in stead of open and off you go.
In the same way Wrap provides the wrap::source and
wrap::load commands, which you can use according to your own
fantasy.
wrap::file command.
wrap::glob command.
| Written by: | Updated: February 19, 2001 |