开发者

PyGTK Spacing in an HBox

开发者 https://www.devze.com 2023-04-06 09:00 出处:网络
I\'m new to GTK, I\'m trying to figure out how to accomplish something like this: +---+------+---+

I'm new to GTK, I'm trying to figure out how to accomplish something like this:

+---+------+---+
|   |      |   |
|   |      |   |
|   |      |   |
|   |      |   |
|   |      |   |
|   |      |   |
+---+------+---+
开发者_开发百科

I want this done in an HBox. How would I accomplish this? Thanks.


It is done with "packing".

I always keep the class reference under my pillow : http://www.pygtk.org/docs/pygtk/gtk-class-reference.html

Samples in the good tutorial found here : http://www.pygtk.org/pygtk2tutorial/sec-DetailsOfBoxes.html

And finally, this shows up something like your drawing :

import gtk as g

win = g.Window ()
win.set_default_size(600, 400)
win.set_position(g.WIN_POS_CENTER)
win.connect ('delete_event', g.main_quit)
hBox = g.HBox()
win.add (hBox)
f1 = g.Frame()
f2 = g.Frame()
f3 = g.Frame()
hBox.pack_start(f1)
hBox.pack_start(f2)
hBox.pack_start(f3)
win.show_all ()

g.main ()

Have fun ! (and I hope my answer is helpful)


The answer is pack_start() and pack_end()

The function has a few parameters you can send to it that give you the desired effect

If you use Louis' example:

hBox.pack_start(f1, expand =False, fill=False)
hBox.pack_start( f2, expand=True, fill=True, padding=50)
hBox.pack_end(f3, expand=False, fill=False)

Hope that helps!

0

精彩评论

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