I am using TclApp to wrap my program and all of its files in a stand-alone executable - and it's working fine for 99% of the files. However, it doesn't seem to be wrapping or recognizing my .ico file...
I am writing a program in Tcl/Tk and I am trying to set the main window icon in the top left like this:
wm iconbitmap .main myIcon.ico
wm iconbitmap .main -default myIcon.ico
After wrapping the program, it will only ruin correctly with the icon if the .exe file is in the same directory as the .ico file - not anywhere else. This is contrary to the whole purpose of wrapping a Tcl program with TclApp in the first place. What should occur is TclApp wrapping the .ico file in with the .tcl file in its Virtual File System, so that no matter where my .exe file is located, it should be able to locate the icon.
I have tried specifying the path more explicitly with:
set icon_home [file dirname [info script]];
wm iconbitmap .main [file join $icon_home myIcon.ico]
wm iconbitmap .main -default [file join $icon_home myIcon.ico]
No luck there...
The error I get then is:
Error Code: TK LOOKUP BITMAP myIcon.ico
bitmap "myIcon.ico" not defined
while executing...
So the two issues I have with this: I read on many blogs and posts on the internet that Tcl/Tk may have some kind of a bug with bitmaps, or something tends to go wrong - no one elaborated. The other problem is that TclApp should be wrapping the icon in with the tcl script so that running my program from anywhere should work just as if it were in the same directory as the .ico file, but it isn't...
So where am I going wrong? Is there something wrong with the Tcl code, is there really a bug with bitmap in Tcl/Tk, or is TclApp not working properly??
I kept working on this issue and I learned something valuable and basically answered my own question:
Using TclApp, the code I posted above in Tcl isn't even necessary. The wrapping program will take your icon and place it wherever it needs to be, no manual coding necessary.
TclApp however, uses a prefix file to generate your executable. This file is necessary to specify if you want to make a starpack (a standalone tcl/tk executable program.) Within this prefix file is embedded a number of different, default icon sizes and color depths for the .ico file, (I am using base-tk8.6-thread.win32-ix86.exe.) Unless all of these icon formats are replaced by your custom icon EXACTLY, they will be visible when the program is done wrapping.
The problem is that I haven't been making sure that my icon file was covering all of the necessary sizes and color depths (256x256 32bpp, 128x128 32bpp, 64x64 32bpp, etc.)
EDIT:
So I contacted ActiveState, and I've found this out: There is a bug in TclApp regarding icons of size 256 x 256. Back when windows Vista came out, Microsoft changed how it dealt with Icon sizes of 256 x 256 or greater; The larger icons started having png file data embedded into them for the sake of compression. This is good, but the problem is that TclApp expects a very specific file size for the custom icons, and if does not receive this, it ignores the size completely; this png information really varies the file size of the icon, so essentially it will not work in TclApp. They say it's a bug that will likely remain unfixed.