TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.84k stars 1.02k forks source link

Selected text coloring #2285

Open infiniteTesch opened 4 months ago

infiniteTesch commented 4 months ago

Hi!

As the subject expose I am interested in changing the color of the selected text in the CTkTextbox. There is no such variable but maybe someone found a workaround? Otherwise it would be a nice add. Thanks for great contribution with this set of custom tkinter widgets.

Best regards InfiniteTesch

JanPanthera commented 4 months ago

import customtkinter as ctk

def set_selection_color(ctk_textbox, bg_color, fg_color): ctk_textbox._textbox.tag_configure("sel", background=bg_color, foreground=fg_color)

window = ctk.CTk()

ctk_textbox = ctk.CTkTextbox(window) ctk_textbox.pack()

ctk_textbox.insert("1.0", "Hello, World!") set_selection_color(ctk_textbox, bg_color="red", fg_color="white")

window.mainloop()

:-)