I'm programming a little application in Python + Gtk3. I'm using a GtkGrid
with one column and two rows.
In the first row I put: a GtkScrolledWindow
, and inside it a TreeView
with two columns.
In the second row I put: a ButtonBox
, and inside it a GtkButton
, a ComboBox
and another GtkButton
.
Question is: the second row (the bottom one with the buttons) has too much space above and below the buttons, so how can I do to set the height of that cell to match the height of the buttons, without "wasting" space above and below?
The code is here and this is a screen-shot of my program:
you're creating the GtkGrid with homogeneous spacing for columns and rows; this means that your columns and rows will receive the same size, which is the maximum natural size between all the columns and rows.
when creating the Grid, remove the row_homogeneous=True
attribute. if you want the TreeView to expand, you should set the hexpand
and vexpand
properties to True
on it, i.e.:
# creamos una grilla
self.grid = Gtk.Grid(column_homogeneous=True,
column_spacing=10,
row_spacing=10)
[...]
# creamos el TreeView
self.treeview = Gtk.TreeView(model=self.liststore)
# set the TreeView to expand both horizontally and vertically
self.treeview.set_hexpand(True)
self.treeview.set_vexpand(True)
GtkGrid is a container and layout manager that respects the horizontal and vertical expansion and alignment flags on the GtkWidget, instead of having packing properties, like GtkBox or GtkTable.