Tkinter鼠标颜色 [英] Tkinter mouse color
问题描述
我现在正在一个项目上,我需要像这样的黑色鼠标光标:
I'm working on a project right now, and I need to get a black mouse cursor like this:
我使用了 root.config(cursor ="arrow black black")
,但是它不想更改光标的颜色.我正在使用Windows,如果有帮助,Windows默认会安装黑色光标.
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.
有人可以帮我吗?
如何更改鼠标指针颜色tkinter?对我不起作用.
我可以更改光标的外观,但不能更改颜色.
I can change how the cursor looks, but not the color.
推荐答案
On Windows systems, the arrow
pointer is mapped to native IDC_ARROW
pointer, the color of which you can't control within tkinter
.
当然,Windows确实有黑色的鼠标指针,但是使用的指针外观取决于当前的配色方案(控制面板"-鼠标"-指针"),因此除非您更改了方案,否则您将看不到它..应用程序不应触摸它,因为它严格是用户首选项.
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.
但是,黑色指针文件位于%windir%\ Cursors \ arrow_r.cur
,因此我们可以在需要时直接使用它:
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()
还值得注意的是,黑色指针具有中等和较大的变体-分别是 arrow_rm.cur
和 arrow_rl.cur
.
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.
这篇关于Tkinter鼠标颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!