TomSchimansky / CustomTkinter

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

CTk 5.2.0 : SelectBackground Not Work In Entry #1859

Open YoussefEssalhi opened 1 year ago

YoussefEssalhi commented 1 year ago

Normal TK :

import tkinter as tk
root = tk.Tk()
root.geometry("250x150")
entry = tk.Entry(root, selectbackground="red")
entry.pack(pady=15)
root.mainloop()

https://github.com/TomSchimansky/CustomTkinter/assets/76540840/b09d9a3c-448b-40c0-a500-d964a82a569b

CustomTkinter :

import customtkinter as CTK
root = CTK.CTk()
root.geometry("250x150")
entry = CTK.CTkEntry(root, selectbackground="red")
entry.pack(pady=15)
root.mainloop()

ValueError: ['selectbackground'] are not supported arguments. Look at the documentation for supported arguments.

.

ghost commented 1 year ago

The error explains itself...

It's not a supported argument. You could ask for this argument to be added in a feature request. However, @TomSchimansky would've left this out for a good reason, perhaps it's not possible with the way CustomTkinter renders widgets.

I'd suggest closing this as "not planned" (gray circle).

loafthecomputerphile commented 1 year ago

@YoussefEssalhi have you tried doing this?

import customtkinter as CTK
root = CTK.CTk()
root.geometry("250x150")
entry = CTK.CTkEntry(root)
entry._entry.configure(selectbackground="red") #right here 
entry.pack(pady=15)
root.mainloop()
ghost commented 1 year ago

I would like to point out that while @loafthecomputerphile's workaround works. It's not recommended to edit the _entry attribute as it's not intended for users. This was probably done on purpose as the selectbackground attribute may have unintended consequences. Furthermore, _entry is probably the tkinter backend widget which is why the selectbackground attribute works.

YoussefEssalhi commented 1 year ago

@dishb I don't think it was done on purpose, I think it was forgotten and should be fixed.

By the way, They give me the same solution of @loafthecomputerphile for another problem, Dishb I hope you will take a look at: