CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

CTkEntry.configure(placeholder_text) does not update placeholder text shown in entry field.

Open wu-kash opened this issue 3 years ago • 3 comments

import customtkinter

customtkinter.set_appearance_mode("System")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue")  # Themes: blue (default), dark-blue, green

app = customtkinter.CTk()  # create CTk window like you do with the Tk window
app.geometry("400x240")

entry1 = customtkinter.CTkEntry(app, placeholder_text = 'entry1')
entry1.grid(row=0, column=0)

entry2 = customtkinter.CTkEntry(app)
entry2.configure(placeholder_text ='entry2', fg_color = 'black')
entry2.grid(row=1, column=0)

app.mainloop()

Using entry.configure(placeholder_text = 'Text') has no effect after the widget is created, but configuring 'fg_color' works.

customtkinter version = 4.5.9 Windows 10

issue

wu-kash avatar Jul 30 '22 10:07 wu-kash

I commented the line 176 from CTkEntry containing the text if self.placeholder_text_active and acquired the resutl from the image below:

print

if "placeholder_text" in kwargs:
            self.placeholder_text = kwargs.pop("placeholder_text")
            #if self.placeholder_text_active:
            self.entry.delete(0, tkinter.END)
            self.entry.insert(0, self.placeholder_text)

I changed wu-kash code to this:


import customtkinter

customtkinter.set_appearance_mode("System")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue")  # Themes: blue (default), dark-blue, green

app = customtkinter.CTk()  # create CTk window like you do with the Tk window
app.geometry("400x240")

entry1 = customtkinter.CTkEntry(app, placeholder_text = 'entry1')
entry1.grid(row=0, column=0)

entry2 = customtkinter.CTkEntry(app)
entry2.configure(placeholder_text ='entry2')
entry2.grid(row=1, column=0)

entry3 = customtkinter.CTkEntry(app)
entry3.configure(placeholder_text ='entry3')
entry3.grid(row=2, column=0)

bt = customtkinter.CTkButton(app, text= "bt 1")
bt.grid(row=3, column=0)

app.mainloop()


|```

felipetesc avatar Jul 30 '22 18:07 felipetesc

It is strange that only entry1 in felipetesc code behaves as it should with the placeholder text, where as entry2 and entry3 are created with the text 'entry2' and 'entry3' inserted in to their entry fields. Erasing the text does reveal the placeholder text for entry2 and entry3

wu-kash avatar Aug 04 '22 12:08 wu-kash

I think we need to investigate how ctk deals with the current focused widget behaviour. Something must to be changed inside the logic responsible for the state of the CTkEntry's text value. For example, right now, once we "enter"(get focus) inside the text field and delete the default value for an empty string the entry should not be filled with the default text again. Perhaps, every widget needs property to let us know if it is "on focus", or not.

felipetesc avatar Aug 04 '22 15:08 felipetesc

Should be fixed now with version 5.0.0.

TomSchimansky avatar Dec 02 '22 22:12 TomSchimansky