CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

name argument for widgets.

Open jericjan opened this issue 2 years ago • 2 comments

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().

jericjan avatar Aug 26 '22 07:08 jericjan

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.

jericjan avatar Aug 29 '22 02:08 jericjan

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

jericjan avatar Aug 29 '22 03:08 jericjan