[Tutor] Customising TK Apps.

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri, 2 Mar 2001 04:24:37 -0800 (PST)


On Fri, 2 Mar 2001, Sharriff Aina wrote:

> I was wondering if one is able to customize TK applications, for example
> the little "tk" that appears in the frame bar of a TK application, my=20
> introductory Python book from O=B4reily does not explain this feature.

I took a quick look at a Tkinter-based game called PySol:

    http://wildsau.idv.uni-linz.ac.at/mfx/pysol/

They have source code available, which is great, because it's one of the
most impressive demonstrations of Tkinter use that I've seen.  (Plus a
great time waster.  *grin*)


In the PySol source code, it appears that they use the call:

    wm_set_icon(top, app.dataloader.findIcon())

(in src/main.py)

and their definition of wm_set_icon() is this:

### src/tk/tkutil.py
def wm_set_icon(window, filename):
    if not filename:
        return
    if os.name =3D=3D "posix":
        window.wm_iconbitmap("@" + filename)
        window.wm_iconmask("@" + filename)
###


wm_iconbitmap() and wm_iconmask() do appear to be real functions, from a
quick interpreter check:

###
>>> x =3D Tkinter.Tk()
>>> x.wm_iconbitmap
<method Wm.wm_iconbitmap of Tk instance at 80929d8>
>>> x.wm_iconmask =20
<method Wm.wm_iconmask of Tk instance at 80929d8>
###


This is all a large guess though, because I'm inexperienced with Tk stuff. =
=20
It does seem to be doing something, though, because in Linux, that part of
the code seems responsible for changing the icon.

Can you check to see that PySol does change its icon appropriately on a
Windows system too?  If so, then we're on the right track.  If not, you'll
still have a fun solitare game installed on your system.  *grin*


Good luck!