Python Forum
Disable entry field and still see value - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Disable entry field and still see value (/thread-26729.html)



Disable entry field and still see value - scratchmyhead - May-11-2020

Is there a way to disable an entry field and yet still see the value in it? For Tkinter.


RE: Disable entry field and still see value - menator01 - May-11-2020

Haven't tested it. But what a search turned up.
https://stackoverflow.com/questions/19876992/in-tkinter-how-i-disable-entry


RE: Disable entry field and still see value - scratchmyhead - May-11-2020

Yeh. I know how to disable the entry but when it's disabled, I still need to see the value in the entry field.


RE: Disable entry field and still see value - menator01 - May-11-2020

This works
import tkinter as tk

root = tk.Tk()
en = tk.Entry(root)
en.insert(0, 'some text here')
en.configure(state=tk.DISABLED)
en.pack()
root.mainloop()



RE: Disable entry field and still see value - scratchmyhead - May-11-2020

That worked. Thank you!


RE: Disable entry field and still see value - menator01 - May-11-2020

On a side note you can change the foreground and background colors in the configure

en.configure(state='tk.DISABLED', disabledbackground='white', disabledforeground='red')