Make stretchable split screen in Tkinter
The main problem with your code is that you're not using PanedWidnow
correctly. For example, you can't pack
or grid
one PanedWindow
inside another. To place one widget inside a PanedWindow
you must use the paned window .add()
method. So, to put m2 inside m1 you must do m1.add(m2)
. Treat a PanedWindow
like a Frame
, and .add()
is the equivalent to .pack()
or .grid()
.
Also, it seems like you're thinking an PanedWindow
is a pane, which it is not. If you want three panes for three side-by-side windows, you only need to create a single instance of PanedWindow
, and then call .add(...)
three times, once for each child window. While you can put paned windows inside paned windows, it's rarely the right thing to do unless one is horizontal and the other is vertical. For most circumstances, a single instance of PanedWindow
is all you need.
You're making this way too complicated. Just following the first example here, I made what you want:
from Tkinter import *root = Tk()m = PanedWindow(root)m.pack(fill=BOTH, expand=1)text1 = Text(m, height=15, width =15)m.add(text1) text2=Text(m, height=15, width=15)m.add(text2) root.mainloop()