[pygtk] gtk.Dialog and buttons width in action_area

Max Usachev maxusachev at gmail.com
Thu May 5 22:10:22 WST 2011


Hello!

I write the simple script that shows the difference in buttons width
if I set label1 or label2 for custom button. The issue, is that label
of this button is big, the OK and CANCEL buttons also changes their
width like custom button. It it possible to keep width of OK and
CANCEL buttons without reference to custom button width.

import gtk
class D(gtk.Dialog):
    def __init__(self):
        gtk.Dialog.__init__(self, 'Test dialog', None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        ok_button = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        cancel_button = self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.set_default_size(600, 250)

        label1 = 'abcdefghijklmnopqrstuvwxyz'
        label2 = 'abcde'
        button = gtk.Button(label2)

        self.action_area.pack_end(button, False, False)
        self.action_area.set_child_secondary(button, True)

        self.show_all()

d = D()
d.run()
d.destroy()
gtk.main_quit()
gtk.main()


Br, Max Usachev


More information about the pygtk mailing list