Skip to content Skip to sidebar Skip to footer

Python Tkinter How Can I Set The Cursor As An Image

I want the cursor to be an image when hovering over my canvas, when i run this it gives me 'bad cursor spec 'pyimage1'' error. Is it possible? from tkinter import* root = Tk() roo

Solution 1:

No, it is not possible to use an image as a cursor. At least, not directly. The cursor option must be one of the following:

  • the name of a standard X11 cursor (see here for a list of valid cursor names)
  • the path to a file in the X11 or X10 cursor format
  • on Windows only, the path to a .ani or .cur file

The definitive description of the cursor option is on the tcl/tk man page for Tk_GetCursor

Since you are using a canvas, you can simulate a cursor with an image by drawing a normal image and updating it's position whenever the cursor moves, though it would lag very slightly being the real cursor.

Post a Comment for "Python Tkinter How Can I Set The Cursor As An Image"