我在網上搜索過但沒有回應。我使用了一個帶有 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
提交
取消