How to insert a string into an Entry widget that is in the "readonly" state?

I am trying to get a record starting with an ellipsis ...

Here is the code I tried:

 e = Entry(rootWin, width=60, state="readonly") e.insert(0, "...") 

I think the error occurs because I'm trying to insert text after the object has been classified as readonly.

How can I insert a string into the Entry Tkinter widget that is in the "readonly" state?

+7
source share
3 answers

This seems to work for me:

 import Tkinter as tk r = tk.Tk() e = tk.Entry(r,width=60) e.insert(0,'...') e.configure(state='readonly') e.grid(row=0,column=0) r.mainloop() 
+6
source

The solution is simple: temporarily set the state to normal, insert the text and set it to turn off.

+6
source

Use the -textvariable parameter to write:

 eText = StringVar() e = Entry(rootWin, width=60, state="readonly",textvariable=eText) .... eText.set("...I'm not inserted, I've just appeared out of nothing.") 
+5
source

All Articles