Vision: Set Cursor icon manually

I want to use an image in the Image Management area to set the cursor icon to, but when I set it to the image, the cursor disappears altogether. Am I getting the path wrong?

My image is stored in the Image Management under: Cursors/green.png

My code to set the cursor is:

from java.awt import Toolkit, Point

tk = Toolkit.getDefaultToolkit()
img = tk.getImage("Cursors/green.png")
c = tk.createCustomCursor(img, Point(event.source.parent.getX(), event.source.parent.getY()), "img")

event.source.parent.setCursor(c)

Thanks in advance

You seem to have neglected saying which version of Ignition, as in 7.9.11 or 8.03 that is in use. I have noted the .awt and would guess that the specific Java or Azure install would also be relevant. Post a response here, because I am guessing that the programmers look for number of participants before selecting questions to answer. For them, this should be easy with the information I requested… G’Day!

You will need to get the image like this:

from java.awt import Toolkit, Point
from com.inductiveautomation.ignition.client.images import ImageLoader

tk = Toolkit.getDefaultToolkit()
img = ImageLoader.getInstance().loadImage("Cursors/green.png") 
c = tk.createCustomCursor(img, Point(event.source.parent.getX(), event.source.parent.getY()), "img")

event.source.parent.setCursor(c)
2 Likes

Awesome, thanks for the help! That works, although a minor correction, line 6 should use img and not myImage.

Cheers!