I'm trying to do something quite standard in GUI design using Python and Tkinter, and I can't figure it out. I'm trying to make something like the following:
+------+----------------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+------+----------------------+
Very simple setup with a sidebar and a main content area. I can manage to lay out the frames no problem, but the problem comes when I go to resize the window. I can get the sidebar to resize just fine, vertically but not horizontally and stuck to the left side, but the main content area refuses to fill the rest of the space horizontally. It's like the sidebar still takes up the same horizontal space even though it's set to resize only in the y
direction.
Here's some very simple code to demonstrate what I mean:
from Tkinter import *
root = Tk()
# sidebar
sidebar = Frame(root, width=200, bg='white', height=500, relief='sunken', borderwidth=2)
sidebar.pack(expand=True, fill='y', side='left', anchor='nw')
# main content area
mainarea = Frame(root, bg='#CCC', width=500, height=500)
mainarea.pack(expand=True, fill='both', side='right')
root.mainloop()
And here's what happens when I try to resize it:
Any ideas? I mean, this has to be doable, right? It's practically a standard.