首页 > 解决方案 > 如何在文本小部件上禁用 I-Beam 光标

问题描述

我正在尝试做一些文本冒险类的游戏,并且我正在使用文本小部件来显示文本。当我的光标悬停在文本小部件上时,它变成了 I-Beam 光标,可能是因为它想要选择它。小部件被禁用并且标志被关闭。

如何关闭 I-Beam 光标以获得更愉快的体验?

window=Tk()
window.resizable(width=False, height=False)
window.title("Text Adventure")

txt=Text(window, font=("Comic Sans", 44), bg="Black", fg="white", width=width-100, borderwidth=0, wrap=WORD, exportselection=0)
txt.tag_configure('center', justify='center')
txt.insert('end', text, 'center')
txt.config(state=DISABLED)
txt.pack()

answer=Entry(window, font=("Comic Sans", 20), bg="Black", fg="Red", borderwidth=0, disabledbackground="Black", disabledforeground="Red", exportselection=0)
answer.place(x=(width/2)-ewidth/2, width=ewidth, height=eheight, y=height-eheight*8)

txt.bindtags((str(txt), str(window), "all"))
answer.bindtags((str(answer), str(window), "all"))

标签: pythonpython-3.xtkinter

解决方案


推荐阅读