I have a textview inside a scrolledwindow that refuses to wrap to words/chars/wordschars no matter how I set the wrap mode. It simply extends the size of itself and its containers as it pleases. Here’s an example:
import gtk
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_default_size(256,256)
scroll = gtk.ScrolledWindow()
scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
view = gtk.TextView()
view.set_wrap_mode(gtk.WRAP_CHAR)
scroll.add(view)
window.add(scroll)
window.show_all()
gtk.main()
How can I make it wrap? If it matters, I need the parent window to be resizeable by the user, just not the text.
You need to set the size request on the
TextView‘s container (which isscrollin your example), not theWindowor theTextViewitself.Try the following: