Mouse Cursors on Tkinter

Eric Brunel eric.brunel at N0SP4M.com
Thu Feb 12 08:20:04 EST 2004


Jeff Epler wrote:
> Here is a small program that works on my system (linux/X11)to change
> the cursor of a Tkinter window:
>     import Tkinter
> 
>     t = Tkinter.Tk()
>     t.configure(cursor=("@/usr/X11R6/include/X11/bitmaps/star",
>         "/usr/X11R6/include/X11/bitmaps/starMask", "white", "black"))
>     t.mainloop()
> 
> As noted in the tk8.3 Tk_GetCursor manpage, this "will not work on
> Windows or Macintosh computers".

The same manpage ( http://www.tcl.tk/man/tcl8.3/TkLib/GetCursor.htm#M9 ) shows a 
form (t.configure(cursor="@/path/to/file.cur")) that works on Windows. You just 
have to define your cursor in a .cur or .ani file; you can do that with Visual 
Studio for example.

On Macintosh's, the form t.configure(cursor="name") works for all cursors 
defined as resources of type crsr or CURS (see the same manpage, a few 
paragraphs above: http://www.tcl.tk/man/tcl8.3/TkLib/GetCursor.htm#M6 )

HTH
-- 
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com




More information about the Python-list mailing list