CustomTkinter
CustomTkinter copied to clipboard
name argument for widgets.
In tkinter, you can give widgets names with the name
argument. I noticed that I cannot do that with CustomTkinter. I mainly use it to find the widgets again with nametowidget()
and then change their text. I've changed my code to use StringVars instead which was, in hindsight, what I should have done in the first place. So my problem is fixed but I'd still need the name
argument still if, for example, I want to pack_forget()
a widget through nametowidget()
.
After looking into the code, I realized that the name actually does get set and creating a CTkLabel actually creates a tkinter.Frame with a tkinter.Label as its child. So instead of using .frame.my_widget_name
I used .frame.!ctklabel.my_widget_name
and it worked as it should.
Nevermind, this becomes an issue when you pack multiple widgets in a row and you end up with widget path names such as .frame.!ctklabel
and .frame.!ctklabel2
. This can get annoying when you add widgets in the future and those path names change.
I made a pull request and it seems to be the fix. #422