Search code examples
pythontkintertkinter-entrycustomtkinter

Customtkinter question about entry placeholder_text and state


Hello I just wanna know if there is any way to see the placeholder_text when the state='readonly'. Because when I give the readonly state I cant see the placeholder_text.

import customtkinter as ctk

gui = Tk()
gui.geometry("200x200") 


entrada= ctk.CTkEntry(gui, placeholder_text= 'Hello World', state= 'readonly')
entrada.pack(pady= 50)


gui.mainloop()

Solution

  • When you set the entry to readonly state initially, the placeholder text cannot be inserted into the entry box.

    So you can set the state to readonly after creating the widget, the placeholder text can then be inserted into the entry box:

    entrada = ctk.CTkEntry(gui, placeholder_text='Hello World')
    entrada.configure(state= 'readonly')