那要怎么做呢? 我无法在此处或通过 Google 找到它。
#Refrences
from tkinter import *
class Interface:
def __init__(self,stage):
topLeft = Frame(stage,bg='black')
test = Entry(topLeft,bg='#2a2a2a',fg='white',insertontime=0)
test.config(insertbackground='white', exportselection=0)
test.grid()
topLeft.grid(row=0,column=0)
def launch():
window = Tk()
lobby = Interface(window)
window.mainloop()
launch()
最佳答案
我假设您希望用户无法编辑输入框?如果是,则必须使用(state="disabled") 的配置参数,例如。
test.config(insertbackground='white', exportselection=0, state="disabled")
不过请注意,我找不到让您的输入框背景保持黑色的方法。希望这有帮助
关于python - 如何禁止在 Python/Tk 程序中选择文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26208695/