I'm trying to make a widget that holds a short text output that the user should be able to copy, but not change. This is what I've come up with:
entry = gtk.Entry()
entry.set_property("editable", False)
entry.unset_flags(gtk.CAN_FOCUS)
It works, but the entry still looks like it's editable, and that looks bad from the user perspective.
I tried entry.set_sensitive(False)
instead, but this both prevents copying, and makes it look completely disabled.
I would like to know how to make a proper read-only text entry, that's grayed out but still active.
Edit: Here's an image of what I'm talking about, although not GTK (and I'm working in a GNOME environment).
Edit 2: It's starting to look like there's no right way to do this with GTK, if someone can confirm this I'll mark the question solved.
You can use a Label
that is selectable and in wrap mode (if the text was more than one line)
label = gtk.Label('multi line text')
label.set_selectable(True)
label.set_line_wrap_mode(True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With