[Tkinter] LONG POST ALERT: Setting application icon on Linux

Jeff Epler jepler at unpythonic.net
Sun Mar 27 18:21:51 CEST 2005


Here is a short program that sets Tk's window icon on Linux.  My window
manager is icewm, and it uses a scaled version of the "flagup" image
both at the upper-left corner of the window and on the task bar entry
for the window.

    import Tkinter
    app = Tkinter.Tk()
    app.iconbitmap("@/usr/X11R6/include/X11/bitmaps/flagup")
    app.mainloop()

As often happens, the Tkinter documentation doesn't tell the whole
story---you have to dig into the Tk documentation.  I started with "man
n wm", and read the following:
    If  bitmap is specified, then it names a bitmap in the standard
    forms accepted by Tk (see the  Tk_GetBitmap  manual  entry for
    details).
OK, on to Tk_GetBitmap... 
    @fileName     FileName  must  be the name of a file containing a
                  bitmap description in the standard X11 or X10 format.
and I happened to know that some bitmaps in this format exist in the
directory I mentioned above.  Note that the "standard X11 format" is
monochrome, so you will not be able to use color images with
"iconbitmap" on Linux.  Tk doesn't support _NET_WM_ICON for setting
full-color icons.

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050327/545b09f6/attachment.pgp>


More information about the Python-list mailing list