[pygtk] PyGTK Button Size Question

engine spot enginespot at gmail.com
Thu Dec 10 00:15:13 WST 2009


great


thank you:)

I will go on learning pygtk development and also I will study glade-3



2009/12/10 John Stowers <john.stowers.lists at gmail.com>

> On Thu, 2009-12-10 at 00:02 +0800, engine spot wrote:
> > Hi John
> >     when I test your code ,I find that the button's height is
> > ok,400px,but the width is fill
> >
> >
> >     when I change vb = gtk.VBox() to vb = gtk.HBox()
> >
> >
> >     run your code ,then the width is 100px, ok,but the height is fill
> >
> >
> >     is it true I need to use gtk's another object but not HBox and
> > VBox?
> >     which object is ok?
>
> import gtk
> Window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> Button=gtk.Button("Hello")
> hb = gtk.HBox()
> vb = gtk.VBox()
> hb.pack_start(vb, False, False)
> vb.pack_start(Button, False, False)
> Window.add(hb)
> Button.set_border_width(0)
> Button.set_size_request(100,400)
> Window.set_default_size(200,600)
> Window.show_all()
> gtk.main()
>
> HBox considers expand and fill pack parameters horizontally, and VBox
> considers them vertically. So depending on your GUI you sometimes need
> both.
>
> But a simple button in a window is not the best way to learn how Gtk+
> GUI packing works, it is not a real world case and will just continue to
> confuse you.
>
> I suggest using glade-3 to design some different GUIs, and experimenting
> with the effect of expand and fill when packing widgets.
>
> In general you should not set minimum/default size (this is not windows
> forms). It is best to accomplish the GUI layout you want using the
> correct application of packing rules, and correct uses of alignments and
> sizegroups.
>
> John
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20091210/129efee6/attachment.htm 


More information about the pygtk mailing list