From: Patrick on
I have been trying to get my custom icon into my starpack on and off
for some time without success. I finally realized what the issue is.

On the tclkit download page http://code.google.com/p/tclkit/wiki/TclkitDownloads
there are two windows versions of tclkit. One with tk and one without.
My application is a windows service and command line executable so
there is no need for the tk. I do however wish (no pun intended) to
change the icon of the app.

The non-tk tclkit does not have the hdr/tclkit.ico in it's metakit
virtual file system (I doubt I am expressing that properly but you get
the idea). It certainly should. in the sdx code (wrap.tcl) the logic
skips the custom icon if hdr/tclkit.ico does not exist in the -runtime
executable. I figured this out by unwrapping sdx.kit, removing some
catches and rewrapping.

I would like to use tclkitsh-8.5.7-win32.upx.exe but would also like
to be able replace the icon. Is there anyway we can get this tclkit
version updated with the tclkit.ico file?

Error message from sdx.kit without catch statements:

couldn't open "hdr/tclkit.ico": no such file or directory
while executing
"open $name"
(procedure "readfile" line 2)
invoked from within
"readfile hdr/tclkit.ico"
(procedure "LoadHeader" line 13)
invoked from within
"LoadHeader $pfile"
("while" body line 12)
invoked from within
"while {[string match -* $a]} {
switch -- $a {
-interp {
set prog [lindex $argv 2]
set argv [lreplace $argv 1 2]
}
-runtime {..."
(file "C:/tclkit/sdx/lib/app-sdx/wrap.tcl" line 101)
invoked from within
"source C:/tclkit/sdx/lib/app-sdx/wrap.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source [file join $b $a.tcl]]"
(procedure "run_sdx" line 17)
invoked from within
"run_sdx"
(file "C:/tclkit/sdx/lib/app-sdx/sdx.tcl" line 59)
invoked from within
"source C:/tclkit/sdx/lib/app-sdx/sdx.tcl"
("package ifneeded app-sdx 2.0" script)
invoked from within
"package require app-sdx"
(file "C:/tclkit/sdx/main.tcl" line 8)
invoked from within
"source C:/tclkit/sdx/main.tcl"
("uplevel" body line 1)
invoked from within
"uplevel [list source [file join $self main.tcl]]"
From: Patrick on
Yes I could do those steps and have already found a workaround.
however I do believe that this is something that needs to be fixed in
the tclkit generation.

>In your error message, I assume your virtual file system is called hdr.

Actually, that filesystem seems to be in the the tclkitsh-8.5.7-
win32.upx.exe executable itself. From looking over the sdx source, the
LoadHeader procedure in wrap.tcl reads the tclkit.ico from the hdr
filesystem in the tclkit executable passed in via the -runtime flag.
That error is thrown by the tclkitsh-8.5.7-win32.upx.exe, but not
tclkit-8.5.7-win32.upx.exe.

I tested this by unwrapping sdk.kit, removing the catch statements and
rewrapping sdx. I also verified that it was the tclkit runtime
executable that is missing the file by printing the file name that
LoadHeader is reading.

What I see happening next is that the icon replacement logic then
looks for the tclkit.ico file in the <appname>.vfs directory. If it
finds it AND there was a tclkit.ico file in the hdr virtual file
system in the tclkitsh-8.5.7-win32.upx.exe executable it will create
an array of the images in the icon files with the element name being
the resolution. It then spins through the images in the new icon file
and if there is a corresponding image (same resolution) in the array
it will search the executable header for the original image and
replace it with the new image.

So there needs to be both a file in the virtual file system hdr called
tclkit.ico and the actual icon in the executable header AND they must
be exactly the same or the find and replace does not work.

> Both tclkitsh and tclkit use the same icon file and the replacement code should work on both in the same way.

They use the same icon file, but in the vfs hdr of both, one has
tclkit.ico and the other does not.

Also I found that in the case of the icon 48x48/256: NOT FOUND, etc.
errors that we've seen the postings about in the tclkit-8.5.7-
win32.upx.exe starpacks, the 48X48 images in the icon file in the hdr
filesystem in that executable do not match exactly the images in the
icon of the exe itself. They are probably very similar but at least
off by one bit causing the NOT FOUND errors.
From: AF on
On Oct 9, 4:46 pm, Pat Thoyts <cnggub...(a)hfref.fbheprsbetr.arg> wrote:
> Patrick <patrick.dunni...(a)activecompliance.com> writes:
> >What I see happening next is that the icon replacement logic then
> >looks for the tclkit.ico file in the <appname>.vfs directory. If it
> >finds it AND there was a tclkit.ico file in the hdr virtual file
> >system in the tclkitsh-8.5.7-win32.upx.exe executable it will create
> >an array of the images in the icon files with the element name being
> >the resolution. It then spins through the images in the new icon file
> >and if there is a corresponding image (same resolution) in the array
> >it will search the executable header for the original image and
> >replace it with the new image.
>
> >So there needs to be both a file in the virtual file system hdr called
> >tclkit.ico and the actual icon in the executable header AND they must
> >be exactly the same or the find and replace does not work.
>
> OK this makes some sense. The kitgen build constructs the tclkit vfs
> during the build and the tclkit.ico file is only included with the gui
> files. I'll add it to the cli files for the
> future. (kitgen/setupvfs.tcl is the script doing this).
>
> >Also I found that in the case of the icon 48x48/256: NOT FOUND, etc.
> >errors that we've seen the postings about in the tclkit-8.5.7-
> >win32.upx.exe starpacks, the 48X48 images in the icon file in the hdr
> >filesystem in that executable do not match exactly the images in the
> >icon of the exe itself. They are probably very similar but at least
> >off by one bit causing the NOT FOUND errors.
>
> I'll see if I can work out whats wrong here. Actually I want to change
> the icon file for something that will work better on Win7 which has a
> tendency to use large icons. I've already committed rendered icons for
> Tcl and Tk so a SVG based rendered set for tclkit will be an
> improvement.
> The icon file used in the tclkit resources is the same file that gets
> copied to the tclkit vfs (from kitgen/files/tclkit.ico) so they should
> be identical.
>
> --
> Pat Thoyts                            http://www.patthoyts.tk/
> To reply, rot13 the return address or read the X-Address header.
> PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

I agree with Patrick, theres really no reason the icon shouldnt be
included in non tk builds. while youre updating to the new icon, would
you like to update sdx to use the tcllib ico module rather than a
naive string replace? I have working code...