If I go to get ctklabel via mouse events, using event.widget.configure(bg_color) shows that there is no such attribute #2557
Unanswered
maxwangwyf
asked this question in
Q&A
Replies: 1 comment
-
@maxwangwyf You need to use Example: import customtkinter
root = customtkinter.CTk()
def get_widget(event):
widget = root.nametowidget(event.widget.winfo_parent()) #get the clicked widget class
widget.configure(bg_color="red")
root.bind("<1>", get_widget) # bind the mouse click
label = customtkinter.CTkLabel(root, text="This is a Label")
label.pack(padx=10, pady=10)
root.mainloop() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
def label_hover(event, text):
bbox = event.widget.bbox("insert")
if bbox is None:
return
event.widget.configure(bg_color="#DDDDDD")
def reset(event):
event.widget.configure(bg_color='#FDFDFD')
Beta Was this translation helpful? Give feedback.
All reactions