[英]Is it possible to set 2 different cursors for a Checkbutton widget (tkinter)?
我在internet上搜索過,但沒有回應。 我使用了一個 tkinter Checkbutton 和 indicatoron=FALSE,這使它看起來只是一個按鈕。
我已經設置了一個 cursor,但我想知道是否可以設置 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()
您可以使其取決於command
中的變量varbutton
:
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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.