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 restores Tk-compatible bg and background aliases for CTk.configure(). These now route through the existing fg_color handling path, so cget("fg_color"), cget("bg"), appearance-mode color application, and child color propagation stay consistent.
Why would you need this? bg and background are not valid arguments (they are not present in ValidTkArgs). In CustomTkinter, "fg_color" is the chosen name to refer to the primary color of all widgets. You also risk confusing it with "bg_color".
Moreover, other widgets also have the "bg"/"background" attribute, but it has been renamed "fg_color".
cget("bg") allows you to retrieve the currently displayed color, taking appearance_mode into account, but this is more a side effect of the implementation than an intended feature. configure(bg=...) should not be used and should result in a type-check failure.
When I moved the constructor arguments to dedicated TypedDict classes, I looked for a way to specify that the cget() method can accept only keys of the TypedDict (something similar to Unpack, but for the keys only). Unfortunately, I didn't find a good solution that didn't require maintaining a separate Literal[...] type with all possible values.
OK, that makes sense. I treated this as a compatibility regression because the legacy unit test from customtkinter used configure(bg=...) / configure(background=...), but your explanation clarifies that fg_color is the intended CustomTkinter API and that cget("bg") working is just an implementation detail.
I agree that adding bg / background to configure() would blur the distinction between fg_color and bg_color, and would also weaken the TypedDict argument checking.
I’ll close this PR shortly and update the pytest updates I'm working through to stop asserting configure(bg=...) support. The test should use configure(fg_color=...) for the supported public API, and avoid treating cget("bg") as a configurable round-trip contract.
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 restores Tk-compatible bg and background aliases for CTk.configure(). These now route through the existing fg_color handling path, so cget("fg_color"), cget("bg"), appearance-mode color application, and child color propagation stay consistent.