Gtk scroll window size in grid

Experimenting with gtk + 3 in python.

Trying to add "Gtk.TreeView" inside the scroll box container to the grid window along with the input field. The problem is that the scroll pane is tiny, and as a result, you can barely see any scroll pane / TreeView. Here is the output image:

enter image description here

Relevant Code:

scroll = Gtk.ScrolledWindow() # Create scroll window scroll.add(self.MatchTree) # Adds the TreeView to the scroll container grid = Gtk.Grid() # Create grid container self.add(Grid) # Add grid to window (self) Grid.add(scroll) # Add scroll window to grid Grid.attach_next_to(self.Entry, scroll, Gtk.PositionType.BOTTOM, 1, 1) # Attach entry to bottom of grid. 

So how do you control the size of the scroll pane?

Cheers, Phil

+4
source share
1 answer

What you need to do is set the hexpand and vexpand in GtkScrolledWindow to True . You can do this when creating the object as follows:

 scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True) 

If you agree with this, I recommend that you use Glade to work with your program interface, it greatly simplifies the work of such problems, since you have easy access to all widgets.

+6
source

All Articles