MGS [2003/09/06] - It seems that KDE can use xpm and png images for Tcl/Tk windows. This is not controlled by Tcl/Tk, but by the window manager, which automatically searches for an icon of the matching window class in the directory /usr/share/icons/mini.
DLR [2003/10/06] - There is a common standard for color icons in toplevel windows for KDE and GTK. Take a look at FreeDesktop [L1 ] and TIP 159 [L2 ]
You can use png images or xpm pixmaps (and maybe others?).
To use an xpm pixmap icon for your app:
1. Create a 16x16 ppm image. I used the Gimp to save a 16x16 ascii ppm image (gimp won't save xpm)
2. Convert ppm to xpm using:
ppmtoxpm myapp.ppm > myapp.xpm
3. Copy myapp.xpm to /usr/share/icons/mini
4. Start wish with the right appname:
wish -name myapp
5. Create new toplevels with the right class
% toplevel .t -class myapp
For reference, I'm using KDE 3.1 on Mandrake 9.1, with a self-compiled Tcl/Tk 8.4.4 (but the default Mandrake-compiled 8.3.3 is also installed in /usr/bin).
Note this has nothing to do with the wm iconbitmap or wm iconwindow commands.
And here's a small icon browser. It re-creates a toplevel window with the selected class.
proc new {} { set sel [.l curselection] if { ![llength $sel] } { return } set index [lindex $sel 0] set class [.l get $index] destroy .t toplevel .t -class $class wm title .t $class } listbox .l -exportselection 0 -yscrollcommand [list .y set] scrollbar .y -orient vertical -command [list .l yview] grid columnconfigure . 1 -weight 1 grid rowconfigure . 1 -weight 1 grid .l -column 1 -row 1 -sticky nsew grid .y -column 2 -row 1 -sticky ns set dir /usr/share/icons/mini foreach f [lsort -dictionary [glob -nocomplain -directory $dir *.png *.xpm]] { .l insert end [file root [file tail $f]] } bind .l <<ListboxSelect>> [list new]
LV In trying the above on SPARC Solaris GNOME, I notice that the directory is different and that even after fixing the directory, I still don't see an icon displayed either in the created window or in the taskbar or in the window stripe.
Anyone know what needs to change above to get these things to work?