Skip to content

Comments

Added name attribute to CTkButton, CTkFrame and CTkBaseClass#1676

Open
octimot wants to merge 5 commits intoTomSchimansky:masterfrom
octimot:master
Open

Added name attribute to CTkButton, CTkFrame and CTkBaseClass#1676
octimot wants to merge 5 commits intoTomSchimansky:masterfrom
octimot:master

Conversation

@octimot
Copy link

@octimot octimot commented May 31, 2023

The name attribute is super useful when dealing with multiple windows and/or observer patterns, since it's the cleanest way to update widgets from different objects/functions etc. using nametowidget()

I would recommend adding this attribute back to all the widgets, if possible.

This was mentioned multiple times, including #419 #422 #961 etc.

I find my proposed method the easiest to implement.

Is there any reason to avoid this?

@nihauc12
Copy link

nihauc12 commented Nov 4, 2023

@TomSchimansky sry to ping but any chance this could get merged in a future version ? This would be really usefull

@FedericoSpada
Copy link
Collaborator

Hi all,
If you save the object inside a variable, why would you need to provide an additional unique name to the widget, just to invoke a function that performs a search operation to retrieve a reference that you already have?
You also lose the type hints given by the IDE since nametowidget() returns "Any".

Let me reverse the question: is there any reason to use this method?
I would avoid adding it just to discourage developers from using it, since I find it quite a bad and old coding practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants