Reputation: 379
I'm working on a project right now, and I need to get a black mouse cursor like this:
I've used root.config(cursor="arrow black black")
, but it doesnt want to change the color of the cursor. I'm using windows, and if this helps, Windows has the black cursor installed by default.
Can anyone help me on this?
how to change the mouse pointer color tkinter? does not work for me.
I can change how the cursor looks, but not the color.
Upvotes: 3
Views: 920
Reputation: 4482
On Windows systems, the arrow
pointer is mapped to native IDC_ARROW
pointer, the color of which you can't control within tkinter
.
Of course, Windows does have a black mouse pointer, but appearance of the pointer in use depends on the current color scheme (Control panel - Mouse - Pointer), so you wouldn't see it unless you'd changed the scheme. Applications should not touch it, since it's strictly a user preference.
However, the black pointer file lives at %windir%\Cursors\arrow_r.cur
, so we can use it directly when needed:
import tkinter as tk
import os
root = tk.Tk()
path = '@%s' % os.path.join(os.environ['WINDIR'], 'Cursors/arrow_r.cur').replace('\\', '/')
root.configure(cursor=path)
root.mainloop()
It's also worth to notice, that the black pointer has a medium and a large variants - arrow_rm.cur
and arrow_rl.cur
respectively.
Upvotes: 3