Python Tkinter read only text field

python, python-2.7, tkinter

Solution

You can set the state of `Text` to disabled:

root = tkinter.Tk()
input = tkinter.Text(root)
input.configure(state=tkinter.DISABLED)

And to enable it again:

input.configure(state=tkinter.NORMAL)

You could also set the styling, to make it look more like your screenshot:

input.configure(state=tkinter.DISABLED,
    borderwidth=0,
    background=root.cget('background'))

And to add text:

input.insert(tkinter.END, "I'd like to suggest that coconuts migrate.")

Also see: Methods on Text widgets.

Problem

How can I create a text field in Tkinter where my mouse pointer becomes active to select and copy that text content, like in the following screenshot? It is a Windows media player song properties window.

Original source

Related problems