'Is it possible to set 2 different cursors for a Checkbutton widget (tkinter)?
I have searched on the internent but without response. I use a tkinter Checkbutton with the indicatoron=FALSE, which makes it seems like it is just a button.
I have set a cursor, but I wanted to know if it is possible to set 2 different cursors for the on/off status of the checkbutton.
For example:
test = tk.Checkbutton(self.frame, text=self.name, indicatoron=False, selectcolor="green", background="red", variable=self.varbutton, command=self.launchsound, cursor="plus")
test.pack()
Solution 1:[1]
You could make it depends on your variable varbutton in your 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()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jizhihaoSAMA |
