I'm working on a PyGTK app with some Buttons that, when clicked, gi开发者_开发问答ve a text entry dialog, then set the text on the button to whatever was entered in the box. The problem is that if the text is longer than the button can show, the button changes size to accomodate. How do I keep GTK Buttons from resizing when the text changes?
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 glade, you can set "Width request" in the "Common" tab.
精彩评论