You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've started running this code through updated unit tests based on my https://github.com/ajkessel/Custom2kinter/tree/m1-test-foundation branch. I will eventually propose those branch as a PR, but first I wanted to get some fixes through that the unit tests have surfaced.
This PR keeps widget theme metadata synchronized when width or height are changed via configure(). This fixes cget("width") / cget("height") returning stale constructor or theme defaults for widgets like CTkButton, CTkLabel, CTkFrame, and CTkEntry after resizing.
Unfortunately, it doesn't work for widgets that inherit from another widget rather than directly from CTkWidget, such as CTkSegmentedButton, CTkToggleButton, and CTkFloatingFrame, since they have dedicated _theme_info attributes, all with slightly different names.
The perfect solution would be to modify all cget() methods from:
elif attribute_name in self._theme_info:
return self._theme_info[attribute_name]
to
elif attribute_name in self._theme_info and attribute_name not in CTkWidgetArgs.__annotations__:
return self._theme_info[attribute_name]
That makes sense. I think your fix will also cover the next failure I encountered with the pytest conversion work: CTkEntry.configure(bg_color="green") updates CTkWidget._bg_color, but CTkEntry.cget("bg_color") currently returns stale _theme_info["bg_color"] ("transparent") before it can delegate to CTkWidget.cget().
Since CTkWidgetArgs.__annotations__ includes width, height, and bg_color, excluding those keys from subclass _theme_info handling should fix both the dimension round-trip failures and the bg_color round-trip failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've started running this code through updated unit tests based on my https://github.com/ajkessel/Custom2kinter/tree/m1-test-foundation branch. I will eventually propose those branch as a PR, but first I wanted to get some fixes through that the unit tests have surfaced.
This PR keeps widget theme metadata synchronized when width or height are changed via configure(). This fixes cget("width") / cget("height") returning stale constructor or theme defaults for widgets like CTkButton, CTkLabel, CTkFrame, and CTkEntry after resizing.