Tkinter provides features to add widgets such as button, text, entry, dialogue and other attributes that help to develop an application. However, tkinter doesn't include a placeholder in the entry widget. Placeholders are the dummy text that appears in the entry widget to inform the user about it.
In this article, we will add a placeholder in the entry widget using the insert(default value, text) function that takes a default value such as 0 along with the placeholder text.
#Import tkinter library from tkinter import* #Create an instance of frame win= Tk() #Set geometry win.geometry("700x400") #Create a text Label Label(win, text="Notepad", font=('Poppins bold', 25)).pack(pady=20) text= StringVar() #Create an entry widget test= Entry(win, textvariable=text) test.pack(fill='x', expand=True, padx= 45, pady=45) test.focus() #Add a placeholder in the entry Widget test.insert(0, "Enter any Text") win.mainloop()
Running the above code will create an Entry Widget with some placeholder in it.