如何更改鼠标指针颜色 tkinter? [英] how to change the mouse pointer color tkinter?

查看:52
本文介绍了如何更改鼠标指针颜色 tkinter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Tkinter 中更改鼠标颜色?我有一个黑暗的背景,鼠标从不显示在 Tkinter 窗口上.

is there a way to change the mouse color in Tkinter? I have a dark background and the mouse never shows over the Tkinter window.

推荐答案

您可以使用 根窗口上的光标选项.改变颜色,例如,

You can change the cursor using the cursor option on the root window. To change the color, e.g.,

root = tk.Tk()
root.config(cursor='clock red red')

有些符号和颜色对我有用,有些则不适用于 Linux,尽管该选项应该与操作系统无关.例如,'clock' 和 'gumby' 有效,'pirate' 无效(但会安静地失败,不会抛出错误).

Some symbols and colors work for me, some don't, on linux, although the option should be operating system agnostic. For example, 'clock' and 'gumby' work, 'pirate' does not (but fails quietly, without throwing an error).

具有讽刺意味的是,我的机器支持船,但不支持海盗.最好不要同时支持两者

Ironically, boat is supported on my machine, but pirates are not. Probably a good call not to support both

回复评论

有时您需要在子小部件上调用它,如果它们的默认行为是覆盖它.例如

Sometimes you need to call this on sub-widgets, if their default behaviour is to overwrite it. For example

root = tk.Tk()
root.config(cursor='gumby red red')
text=tk.Text(root)
text.pack()
# oh no cursor is boring again! That makes sense, the default
# text cursor is slightly different than the root cursor
text.config(cursor='boat blue blue') # phew!

请注意,如果您想更改插入光标,请参见这里,但是tldr insertbackground.请注意,您可能正在使用不支持更改颜色的光标,在这种情况下,请尝试使用不同的光标

Note that if instead you wanted to change the insertion cursor, see here, but tldr insertbackground. Note that you may be using a cursor that doesn't support changing colors, in which case try a different cursor

这篇关于如何更改鼠标指针颜色 tkinter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆