是否可以为 Checkbutton 小部件(tkinter)设置 2 个不同的光标?

我在网上搜索过但没有回应。我使用了一个带有 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()


UYOU
浏览 147回答 1
1回答

红颜莎娜

你可以让它取决于varbutton你的变量command:import tkinter as tkdef changeCursor():    if varbutton.get():        test['cursor'] = 'hand2'    else:        test['cursor'] = 'plus'    # passr = 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()
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python