0

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.

Pwnna
  • 9,178
  • 21
  • 65
  • 91
  • I suppose the drawings you give are "frames" ? Do the user have to see them ? Do you want a specific width ? Your answers will help me write a good sample for you. – Louis Sep 22 '11 at 07:16
  • Well, not exactly a specific width, more like the left and the right has the same width, and the center has a bigger width (setting a specifc width would be fine, though) – Pwnna Sep 22 '11 at 16:57

2 Answers2

0

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)

Louis
  • 2,854
  • 2
  • 19
  • 24
  • That doesn't help me though.. the packing will automatically expand the frames if there are content, but I want the center frame to always be larger and the side ones to be always identical – Pwnna Sep 22 '11 at 14:17
  • Well, use the available parameters in both pack-start and pack-end methods and you're gone. – Louis Sep 22 '11 at 19:47
0

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!

Wes
  • 954
  • 13
  • 25
  • That would just give it a padding, it doesn't actually extend the box (and its content). Also the False on the fill would cram my other boxes... – Pwnna Sep 23 '11 at 01:16