Skip to content

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

@Wizard0f0zz
Copy link

Wizard0f0zz commented Feb 13, 2025

Hi Kr8589, when will this be available? Also, can this parameter be setup in theme file?

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.

2 participants