I'm trying to create a custom cursor in a Kivy app. I've looked at approaching it from the angle of tying the position of a Kivy widget to the cursor position. However, this method is extremely finicky and not very clean. If worst comes to worst I can stick with that approach, but I was curious if there is a way to create a custom cursor within Python itself.
I've looked at countless examples of creating a custom cursor in Python and all of the ones I have found require destroying and recreating the actual windows cursor. Every example I have found strongly discourages this approach because if you quit out of your program before recreating the cursor, then it obviously doesn't recreate itself and you're left with the custom cursor (which CAN be manually reset, but my program is for customer use). I am aware that you can set the cursor in Python to be a crosshair, a hand and a select variety of cursors, but I would like to use an actual image for the cursor.
Following is an example of the code that destroys and recreates your cursor (the method that is recommended to avoid). This snippet of (working) code can be found in the answer to How to change cursor image in Python .
hold = win32gui.LoadImage(0, 32512, win32con.IMAGE_CURSOR,
0, 0, win32con.LR_SHARED )
hsave = ctypes.windll.user32.CopyImage(hold, win32con.IMAGE_CURSOR,
0, 0, win32con.LR_COPYFROMRESOURCE)
hnew = win32gui.LoadImage(0, 'file.cur',
win32con.IMAGE_CURSOR, 0, 0, win32con.LR_LOADFROMFILE);
ctypes.windll.user32.SetSystemCursor(hcursor, 32512)
time.sleep(5)
#restore the old cursor
ctypes.windll.user32.SetSystemCursor(hsave, 32512)
Does my answer lie in an adaptation of the above code? Or is there a better approach altogether? I know it has to be possible to set a custom cursor in Python, I'm just pulling up blanks every source I go to.
P.S. I apologize in advance about my question, this is my first one on Stack haha.