Is there a way to make the Tkinter text widget read only? Is there a way to make the Tkinter text widget read only? python python

Is there a way to make the Tkinter text widget read only?


You have to change the state of the Text widget from NORMAL to DISABLED after entering text.insert() or text.bind() :

text.config(state=DISABLED)


text = Text(app, state='disabled', width=44, height=5)

Before and after inserting, change the state, otherwise it won't update

text.configure(state='normal')text.insert('end', 'Some Text')text.configure(state='disabled')


Very easy solution is just to bind any key press to a function that returns "break" like so:

import Tkinterroot = Tkinter.Tk() readonly = Tkinter.Text(root)readonly.bind("<Key>", lambda e: "break")