Reputation: 337
I am trying to make the TEXT widget read-only, so the user can view it yet cannot edit it. I saw the state of "readonly" being used in another SO question, however it throws this error at me
_tkinter.TclError: bad state "readonly": must be disabled or normal
My code is below
e = Text(root ,height=10, width=50).config(state="readonly")
e.place(x=1,y=1)
Upvotes: 0
Views: 3069
Reputation: 15837
There's no such a possible value "readonly"
for the state
of a Text
widget. You can disable it, setting the state to "disabled"
(and you can do it directly in the constructor):
e = Text(root, height=10, width=50, state='disabled') # no need to call config
From the Tk documentation:
If the text is disabled then characters may not be inserted or deleted and no insertion cursor will be displayed, even if the input focus is in the widget.
I think you should use a Label
, if you want just to show some text, that's why labels exist.
Upvotes: 3