Phil Donovan
Phil Donovan

Reputation: 1265

Gtk scroll window size in a grid

Experimenting with Gtk+3 in python.

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

enter image description here

The relevant code is:

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 area?

Cheers, Phil

Upvotes: 4

Views: 2993

Answers (1)

asermax
asermax

Reputation: 3123

What you need to do is to set the hexpand and vexpand attributes of the GtkScrolledWindow to True. You can do this on object creation like this:

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

If you are up to it, I recommend you use Glade to work your program's interface, it makes a lot simpler to work out this kind of problems, since you have easy access to all the widgets properties.

Upvotes: 6

Related Questions