[pygtk] Window grows too much when loading data into TreeView
walter at translate.org.za
Tue Oct 14 15:23:37 WST 2008
Roberto Bonvallet wrote:
> Dear all,
> I have written a small PyGTK program for the first time in order to
> help me visualize some data, but I have this problem I hope someone
> can help me to solve.
> The window contains a VBox, whose bottom cell contains a HBox with a
> TreeView and its VScrollbar. The TreeView is populated by loading
> data from a file when the user presses a button.
> I tested my program in a tiled window manager (Ion3), where the window
> size is fixed by the containing tile, and it works fine: the TreeView
> fits the window and can be scrolled down with the VScrollbar.
> But now I've run my program in Gnome, and now the TreeView grows to
> show all its contents, so I get a very tall window that doesn't fit
> the screen and the scrollbar doesn't work, so I can only see the first
> handful of rows.
> I have set the window default size, and changed the window size after
> loading the data, but it doesn't help.
> The relevant widget creation and packing code:
> self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> self.window.set_default_size(200, 400)
> self.vbox = gtk.VBox()
> self.data_box = gtk.HBox()
> self.vbox.pack_start(self.data_box, expand=True)
> self.data_view = gtk.TreeView()
> self.data_box.pack_start(self.data_view, expand=True)
> v = self.data_view.get_vadjustment()
> self.sb <http://self.sb> = gtk.VScrollbar(adjustment=v)
> self.data_box.pack_start(self.sb <http://self.sb>, expand=False)
> Does anybody know what's wrong, and how could I solve this?
> I'd be very thankful for any hint.
> Roberto Bonvallet
Have you tried packing your TreeView in a ScrolledWindow? You can then
use the ScrolledWindow's set_policy() method to specify when to shown
Walter Leibbrandt http://translate.org.za/blogs/walter
Software Developer +27 12 460 1095 (w)
* Switching from Subversion to git
* The first official release of Spelt
* Auto-completion and auto-correction for Gtk+ widgets
More information about the pygtk