Doktoro Reichard
Doktoro Reichard

Reputation: 597

tkinter - Expanding a Listbox inside a Notebook

As the title says, I'm trying to make a Listbox object occupy all space that is inside a Notebook pane.

Here is a screenshot of what I have so far:

Part of a GUI I'm working on. As you can see, the space left on the right is far from appealing

What I want to do is to expand the Listbox to occupy all the space that's on the right. I know that if I say listbox['width'] = value to a high enough value, the Notebook panes' titles will not bug this. However I am looking for alternative ways to do this, either resorting to grid() (what I'm using in this project) or pack().

Upvotes: 0

Views: 904

Answers (2)

Bryan Oakley
Bryan Oakley

Reputation: 385900

If you're using pack, do it like this:

scrollbar.pack(side="right", fill="y")
listbox.pack(side="left", fill="both", expand=True)

If you're using grid, make sure you call columnconfigure on column 0 and give it a weight that is greater than zero, which will cause it to expand and fill up any extra space in the container.

containing_frame.grid_columnconfigure(0, weight=1)

Upvotes: 1

The-IT
The-IT

Reputation: 728

Try putting sticky = E for the scroll bar grid and then try sticky = EW in the list box.

If that does not work, trying playing around with the column spans of the widgets.

Upvotes: 0

Related Questions