I'm trying to create a multiline button with PyGTK. I have a label added to my subclass of gtk.Button, but I'm having trouble sizing the label to the button. If the label makes it's own size, there is no text wrapping even with
In general, this is not possible with GTK+, because there is no stage where widgets "negotiate" sizes. Instead, widgets report their required size and after that container allocate some areas (normally, equal to or larger than required). In GTK+ 3 there will be width-for-height negotiation, so if your button (rather its label) is anyway going to be allocated several lines, it will be able to request less width and wrap its text.
In 2.x the best you can do is probably use
width_chars property of
import gtk window = gtk.Window () align = gtk.Alignment (0.5, 0.5) button = gtk.Button ('a very long, possibly multiline text') label = button.child label.props.wrap = True label.props.width_chars = 20 window.set_default_size (500, 500) window.connect ('destroy', lambda *ignored: gtk.main_quit ()) window.add (align) align.add (button) window.show_all () gtk.main ()