views:

251

answers:

1

I'm working with PyGTK, trying to come up with a combination of widgets that will do the following:

  • Let me add an endless number of widgets in a column
  • Provide a vertical scrollbar to get to the ones that run off the bottom
  • Make the widgets' width adjust to fill available horizontal space when the window is resized

Thanks - I'm new to GTK.

+6  A: 
  • An endless number of widgets in a column: Sounds like a GtkVBox.
  • Vertical scrollbar: Put your VBox in a GtkScrolledWindow.
  • Horizontal stretching: This requires setting the appropriate properties for the VBox, ScrolledWindow, and your other widgets. At least in Glade the defaults seem to mostly handle this (You will probably want to change the scrollbar policy of the ScrolledWindow).

Now for the trick. If you just do what I've listed above, the contents of the VBox will try to resize vertically as well as horizontally, and you won't get your scrollbar. The solution is to place your VBox in a GtkViewport.

So the final hierarchy is ScrolledWindow( Viewport( VBox( widgets ) ) ).

Steve S
I was doing about that, but your pointing to Glade for the defaults made me review my way of packing the bottom-level widgets into the VBox. Thanks for the help!
JasonFruit
thanks for the viewport tip :)
Sujoy