开发者

Keep PyGTK Button from Resizing on Label Change

开发者 https://www.devze.com 2022-12-27 19:25 出处:网络
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 th

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消