CustomTkinter
CustomTkinter copied to clipboard
Binding mouse button to a label
Hello, Custom Tkinter is a brilliant library, but I have an issue with binding the left button of the mouse to a label. I want that when you click in a piece of text, a function executes, but it's not working. It worked with normal Tkinter.
Here's an example:
self.right_label = ctk.CTkLabel(top_text_frame, text='Sudoku', text_font=('Segoe UI', 15))
self.right_label.grid(column=2, row=0, padx=20)
self.right_label.bind("<Button-1>", lambda event, btn="right": self.change_to(btn))
And here's the function (it's not important):
def change_to(self, btn, event=None):
if self.which_frame == "Coloring" and btn == "right":
self.left_label.configure(foreground='black')
self.mid_label.configure(text='Sudoku')
self.right_label.configure(foreground='#F0F0F0')
self.which_frame = "Sudoku"
self.sudoku_frame.tkraise()
elif self.which_frame == "Sudoku" and btn == "left":
self.left_label.configure(foreground='#F0F0F0')
self.mid_label.configure(text='Coloring')
self.right_label.configure(foreground='black')
self.which_frame = "Coloring"
Thank you!!!!
It will work in the next version 5.0.0, which will be released soon.
Binding is now implemented with version 5.0.0.