Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mouse Cursors on Tkinter

978 views
Skip to first unread message

Mauricio Inforçati

unread,
Feb 11, 2004, 1:26:08 PM2/11/04
to pytho...@python.org
Hi,
How can I change my mouse cursor to an own file.cur cursor?
I tried setting "cursor" option to the file(widget['cursor']='file.cur'), to a pointer of this file (@widget['cursor']='file.cur'), to a Image instance of this cursor and none of this options worked.
What can I do?

Jeff Epler

unread,
Feb 11, 2004, 1:40:21 PM2/11/04
to Mauricio Inforçati, pytho...@python.org
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".

Jeff

Jørgen Cederberg

unread,
Feb 12, 2004, 3:04:37 AM2/12/04
to

Hi

actually you _can_ change the cursor on Windows computers:

from Tkinter import *
root = Tk()
root.configure(cursor='spraycan')
root.mainloop()

This will show a spraycan (quite ugly though) in the window.

The names of the cursors can be found in "Tkinter reference: A GUI for
Python", located at http://www.nmt.edu/tcc/help/lang/python/tkinter.html

Regards
Jorgen Cederberg

Jørgen Cederberg

unread,
Feb 12, 2004, 3:09:46 AM2/12/04
to
Jørgen Cederberg wrote:
> Hi
>
> actually you _can_ change the cursor on Windows computers:
>
> from Tkinter import *
> root = Tk()
> root.configure(cursor='spraycan')
> root.mainloop()
>
> This will show a spraycan (quite ugly though) in the window.
>
> The names of the cursors can be found in "Tkinter reference: A GUI for
> Python", located at http://www.nmt.edu/tcc/help/lang/python/tkinter.html
>
> Regards
> Jorgen Cederberg
>

Mr. Cederberg: Well Jorgen, you better wake up before answering any
newsgroups postings. The OP asked for his _own_ cursors.

Jorgen Cederberg: Gee I'm really sorry, I'll try to remember that. And I
don't know how to do that on a windows machine.

Regards
Jorgen Cederberg

Eric Brunel

unread,
Feb 12, 2004, 8:20:04 AM2/12/04
to

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

0 new messages