简体   繁体   English

如何在 Tkinter 中更改文本光标颜色?

[英]How to change text cursor color in Tkinter?

I have a text widget with dark background and I can't see the cursor's position.我有一个深色背景的文本小部件,我看不到光标的位置。 Is there any way to change the (blinking) text cursor's color?有没有办法改变(闪烁)文本光标的颜色?

您可以将文本小部件的insertbackground选项更改为您想要的任何内容。

Tk 中文本光标颜色的选项是-insertbackground

textWidget.config(insertbackground=...)

For python version 3对于 python 版本 3

import tkinter as tk

textfield = tk.Entry(root)
textfield.configure(bg="#1C6C0B", insertbackground='white')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM