How can I word wrap text inside a PyGTK TreeView?
Text in a gtk.TreeView is rendered using a gtk.CellRendererText, and wrapping text comes down to setting the right properties on your cell renderer. In order to get text to wrap, you need to set the wrap-width
property (in pixels) on the cell renderer. You probably also want to set the wrap-mode
property to something sensible. For example:
renderer.props.wrap_width = 100
renderer.props.wrap_mode = gtk.WRAP_WORD
Unfortunately, if you want adjustable-width word wrapping on a column, PyGTK won't do that for you automatically. You should be able to dynamically set wrap-width
to get the right effect though; there are known workarounds like this for gtk.Label, and the guides linked in sproaty's answer seem to do a similar thing.
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