Save PyGTK button to resize on label

I'm working on a PyGTK application with some buttons that, when clicked, gives a text input dialog and then sets the text on the button to whatever was entered in the field. The problem is, if the text is longer than the button can display, the button resizes to fit. How to resize GTK buttons when text changes?

+2


a source to share


1 answer


Have you tried set_size_request?

http://library.gnome.org/devel/pygtk/stable/class-gtkwidget.html#method-gtkwidget--set-size-request

button = gtk.Button("text on button")
button.set_size_request(width=30, height=20)

      



See: http://www.pygtk.org/docs/pygtk/class-gtkwidget.html#method-gtkwidget--set-size-request

In the clearing, you can set the "Request Width" on the "General" tab.

+1


a source







All Articles