Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "selectforeground" and "selectbackground" attributes to CTkComиobox, CTkEntry and CTkTextbox #2341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kr8589
Copy link

@kr8589 kr8589 commented Mar 31, 2024

selectbackground − Background color for the selected items of the widget.

selectforeground − Foreground color for the selected items of the widget.

Tkinter's Entry, Textbox, and Combobox have these attributes.

In CTkEntry and CTkTextbox, I added them to the dictionaries _valid_tk_entry_attributes and _valid_tk_text_attributes. For CTkCombobox, I used the default template of the file and added it like the others.

I tested it with code and select text in widgets with mouse:

selected_color = self._apply_appearance_mode(ctk.ThemeManager.theme["CTkButton"]["fg_color"])
self.Combo_Box_my = ctk.CTkComboBox(self.Frame_my, hover=True, values=list(mylist.keys()), command=self.mycommand, selectbackground=selected_color)
self.Entry_my = ctk.CTkEntry(self.Frame_my, selectbackground=selected_color)
self.scrolled_text_my = ctk.CTkTextbox(self.Frame_my, state='disabled', width=400, height=200, selectbackground=selected_color) 

result: theme button color (green, blue or dark-blue) selected text on combobox's entry, entry and textbox. selectforeground color behaves similarly but for foreground. If text in textbox already has color, the color doesn't change.

self.Combo_Box_my = ctk.CTkComboBox(self.Frame_my, hover=True, values=list(mylist.keys()), command=self.mycommand, selectbackground="red") 

result: red selected text on combobox's entry, similar behavior for entry and textbox.

self.Combo_Box_my = ctk.CTkComboBox(self.Frame_my, hover=True, values=list(mylist.keys()), command=self.mycommand)

result: default (windows 10 blue) selected text on combobox's entry, entry and textbox, similar behavior for entry and textbox.

Images:
image
image
image

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.

1 participant