我在网上搜索过但没有回应。我使用了一个带有 indicatoron=FALSE 的 tkinter Checkbutton,这让它看起来只是一个按钮。我已经设置了一个光标,但我想知道是否可以为复选按钮的开/关状态设置 2 个不同的光标。例如:test = tk.Checkbutton(self.frame, text=self.name, indicatoron=False, selectcolor="green", background="red", variable=self.varbutton, command=self.launchsound, cursor="plus")
test.pack()
1 回答

红颜莎娜
TA贡献1842条经验 获得超13个赞
你可以让它取决于varbutton你的变量command:
import tkinter as tk
def changeCursor():
if varbutton.get():
test['cursor'] = 'hand2'
else:
test['cursor'] = 'plus'
# pass
r = tk.Tk()
varbutton = tk.BooleanVar()
test = tk.Checkbutton(r, text="a", indicatoron=False, selectcolor="green", background="red", cursor="plus", command=changeCursor, variable=varbutton)
test.pack()
r.mainloop()
添加回答
举报
0/150
提交
取消