Changing cursors...

Greg Ewing greg.ewing at
Tue Nov 2 08:11:46 EST 1999

Gordon McMillan wrote:
> Xtian Muirhead writes:
> >
> > I've been having a play with Tkinter, and I've ported across a
> > program that I wrote while learning VB, but I've had one problem.
> > There's one step that has a chunk of processing which takes a few
> > seconds to complete. In the old program, I changed the cursor to
> > an hourglass at the start, and reset when the program finished.
> > Trying to do the same in the new version doesn't seem to work:

I managed to kludge my way around this problem using the
following technique:

    root = Tkinter._default_root
    x, y = root.winfo_pointerxy()
    w = root.winfo_containing(x, y)
    if w:
        old_cursor = w['cursor']
        w.configure(cursor = "watch")
	w.configure(cursor = old_cursor)

This finds the widget that the mouse pointer happens to be
over, changes its cursor, and forces this to become the
current cursor by doing an update. The change back again
doesn't take effect until the event loop is returned to
or another update occcurs.

(This works on Windows, and will probably work on the Mac
(if Tkinter works there at all). It almost certainly won't 
work on unix under X, because X maintains the cursor 


More information about the Python-list mailing list