Version 8 of wm iconbitmap

Updated 2003-04-01 17:16:45

wm iconbitmap window ?bitmap?

If bitmap is specified, then it names a bitmap in the standard forms accepted by Tk (see the Tk_GetBitmap manual entry for details). This bitmap is passed to the window manager to be displayed in window's icon, and the command returns an empty string. If an empty string is specified for bitmap, then any current icon bitmap is cancelled for window. If bitmap is specified then the command returns an empty string. Otherwise it returns the name of the current icon bitmap associated with window, or an empty string if window has no icon bitmap. On the Windows operating system, an additional flag is supported: wm iconbitmap window ?-default? ?image?. If the -default flag is given, the icon is applied to all toplevel windows (existing and future) to which no other specific icon has yet been applied. In addition to bitmap image types, any (name of a) file which contains a valid Windows icon is also accepted (usually .ico or .icr files). Tcl will first test if the files contains an icon, and if that fails, test for a bitmap. (Tcl Help, bold addition by RS)


Eric Brunel writes, on news:comp.lang.tcl ,

Since I just spent half an hour to figure out how this works, I thought someone might be interested. The exact syntax is:

 wm iconbitmap <window> <icoFileName>

and not:

 wm iconbitmap <window> @<icoFileName>

(the "regular" bitmap files required the "@" in front of them and the manual is a tad unclear on this point...).


Therefore, typing

 wm iconbitmap . myicon.ico

(where myicon.ico can be either this relative name, or even a full pathname) results in Tk reading the file to determine whether it is an icon or a bitmap file.


Recently tclguy mentioned on comp.lang.tcl that a) the @ isn't required for Windows, but is for Unix and that b) windows requires .ico for the format of the file, while Unix requires .xbm formatted files.

While these differences do mean that you have to code different lines for Windows vs Unix, considering that wm is pretty platform/desktop specific that is going to have to be something one deals with.


Question 1 : what does one do if they want to use on Windows a .bmp file for an icon?

Vince I think in Tcl 8.4, some uses with a Tk bitmap do work.

Question 2 : what does one do if one wants to make the icon in Tcl itself, e.g. use a string as input for the icon ? - RS: Oh yes - if we had a "gateway" to photo images, we could use base64 encoded data, or strimjes (see strimj - string image routines, or files - a grand unification.


Tk Syntax Help - Category Command