How to wrap a tcl file to .exe on windows?

263 views
Skip to first unread message

neutrino

unread,
Apr 2, 2014, 1:30:48 PM4/2/14
to sta...@googlegroups.com
there is a file chess.tcl in C:\source , this file works well when executed
on wish with the command source . in chess.tcl , i use some png files and a
txt. these files are also in C:\source. now i want to wrap these files into
an exe . i follow the steps on wiki . but it does't show how to include
these extra png files and txt files. is there anyone who knows the detail
steps to do this ?
thanks for your help



--
View this message in context: http://tcl.2662.n7.nabble.com/How-to-wrap-a-tcl-file-to-exe-on-windows-tp65312.html
Sent from the Tcl Starkit mailing list archive at Nabble.com.

CJL

unread,
Apr 6, 2014, 4:19:45 PM4/6/14
to sta...@googlegroups.com, zjy19...@163.com
On Wednesday, 2 April 2014 18:30:48 UTC+1, neutrino wrote:
there is a file chess.tcl in C:\source , this file works well when executed
on wish with the command source . in chess.tcl , i use some png files and a
txt. these files are also in  C:\source. now i want to wrap these files into
an exe . i follow the steps on wiki . but it does't show how to include
these extra png files and txt files. is there anyone who knows the detail
steps to do this ?
thanks for your help

You need a copy of sdx.kit (from http://equi4.com/starkit/sdx.html), and a tclkit.exe.

If you don't already have a tclkit.exe, some relatively old tclkits are available here : http://equi4.com/tclkit/download.html, some slightly more recent ones here : http://rkeene.org/projects/info/wiki/Tclkits

If you want/need 8.6.x, I'm not sure which the current/preferred tclkit build system is, but I've had good results with kitcreator (http://kitcreator.rkeene.org/fossil/index)

To match these instructions, put tclkit.exe and sdx.kit in c:\Source

Now, in a command prompt:

> c:
> cd \source

# We need a copy of tclkit.exe to use for the final executable
> copy tclkit.exe runtime.exe

# Wrap the script into a .kit
> tclkit sdx.kit qwrap chess.tcl

# Unwrap the .kit into a vfs directory structure
> tclkit sdx.kit unwrap chess.kit

# Your chess.tcl now exists as chess.vfs/lib/app-chess/chess.tcl
# so delete the original (or move it if you prefer)
> del chess.tcl

# The .kit was a temporary step, so remove it too
> del chess.kit

# Move the PNGs inside the vfs
> mkdir chess.vfs\images
> move *.png chess.vfs\images

# You should now be able to wrap into an executable
# NOTE: the value for '-runtime' must refer to a COPY of tclkit.exe
#       It cannot be the same executable that you are running
> tclkit sdx.kit wrap chess -runtime runtime.exe

You should now have a chess.exe, but it won't know where to find the PNG files.

Edit chess.vfs\lib\app-chess\chess.tcl along these lines:

Before :
    set img [image create photo -file king.png]

After :
    set kingFile [file join $starkit::topdir images king.png]
    set img [image create photo -file $kingFile]

NOTE : You do not have to wrap every time you make a change. You can run the contents of the VFS in unwrapped form:

> tclkit.exe chess.vfs\main.tcl

Then, when you are happy with your app, perform the final wrap step again to make an executable:
> tclkit sdx.kit wrap chess -runtime runtime.exe


NOTE : The above is all written from memory and by a Mac user, so you may have to make some slight changes to suit your system.

If your code never does a 'cd', you can get away with just specifying relative paths starting with chess.vfs :

% set pathToFile [file join chess.vfs images whatever.png]

But, it's safer and hardly any extra typing to use starkit::topdir, from which you can build paths:

% set pathToFile [file join $::starkit::topdir images whatever.png]

There is also a variable, starkit::mode, that tells you whether you are running wrapped or unwrapped, but it is unlikely that you will need to make the distinction.

Chris

neutrino

unread,
Apr 18, 2014, 10:44:10 AM4/18/14
to sta...@googlegroups.com
Thank you so much for your reply .I will try the steps you listed. I find a
tool called Mytcl looks like VC++ written by In-Hak Min from South Korea.It
is easy to make an exe with it. But when I use PNGs, there are some errors
.It seems that the Mytcl can't read PNGs, but the packge "img::png" really
exists when I check it with the command "package names" . This confused me a
lot .Then I convert the PNGs into GIFs. I finally get the chess.exe like
this:
<http://tcl.2662.n7.nabble.com/file/n65440/%E5%9B%BE%E7%89%871.png>

I will try the steps you listed to see if it is ok with the PNGs. thankyou
again for your reply.

PS:My tcl version is 8.6.1, do I have to make a 8.6.1 tclkit.exe ?



--
View this message in context: http://tcl.2662.n7.nabble.com/How-to-wrap-a-tcl-file-to-exe-on-windows-tp65312p65440.html

CJL

unread,
Apr 24, 2014, 4:49:42 AM4/24/14
to sta...@googlegroups.com, zjy19...@163.com
On Friday, 18 April 2014 15:44:10 UTC+1, neutrino wrote:
Thank you so much for your reply .I will try the steps you listed. I find a
tool called Mytcl looks like VC++ written by In-Hak Min from South Korea.It
is easy to make an exe with it. But when I use PNGs, there are some errors
.It seems that the Mytcl can't read PNGs, but the packge "img::png" really
exists when I check it with the command "package names" . This confused me a
lot.

I don't know MyTcl or how .exe files it builds compare to tclkits. I can tell you that to make a package available to a tclkit app, simply copy it into a subdirectory of chess.vfs\lib
It might be that img::png is available on your system, but is not being built into chess.exe by MyTcl.

 
Then I convert the PNGs into GIFs. I finally get the chess.exe like
this:
<http://tcl.2662.n7.nabble.com/file/n65440/%E5%9B%BE%E7%89%871.png>

I will try the steps you listed to see if it is ok with the PNGs. thankyou
again for your reply.

PS:My tcl version is 8.6.1, do I have to make a 8.6.1 tclkit.exe ?

You will need a tclkit.exe that supports whatever Tcl and Tk features you have used in your scripts. Generally features from a recent version can be added to an older version using packages, but it is often easier and neater to just use the newest version. To solve your PNG problem : 8.6 introduces native support for PNGs without needing img::png, or for an older tclkit, copy the img package into chess.vfs\lib\img (note - a full 'img' package will have .dlls for all sorts of image formats - you can leave out any that aren't relevant to PNG to make a smaller .exe)

Chris

Reply all
Reply to author
Forward
0 new messages