views:

17

answers:

1

I have a GTK widget, in this case, a TreeView. It starts off pretty small and compressed, as there's no text in it besides the columns names. As I add things, it grows horizontally to cover the text and vertically to cover the extra rows. If I then take those away, it retains its expanded size.

It's kind of annoying for your window to always be resizing as you add things. My question is - how can I "pre-"size the widget? Like one way would be to fill it with junk text that I think is the biggest size it can get, and then remove the text, but that won't look very pretty. Is there a better way?

+1  A: 
  1. Simplest answer: treeview.set_size_request(width, height) (but then your tree view won't grow when it needs to afterwards.)
  2. Is your tree view in a box? Have you tried packing it with expand=True and fill=True?
  3. window.set_default_size(width, height) on your whole gtk.Window is the best solution, because that "pre-"sizes the window as you say. It can still grow, or be resized smaller by the user.
ptomato
ah the 3rd option seems like what I want. It is packed w/ expand and fill set to True, as it does grow correctly, but it just starts off small.
Claudiu
i tried the 3rd option, but even though the treeview widget expands, it doesn't expand any columns except the last one. Is there any way to make them grow more homogeneously?
Claudiu
You can set the `min-width` properties of your `gtk.TreeViewColumn` s to a reasonable value so that they don't start at zero, or call the `gtk.TreeView.columns_autosize()` method at certain times to autosize the columns.
ptomato