Page 1 of 1

Re: tkinter panedWindow

Posted: Thu Sep 15, 2016 1:35 pm
by RogerW
I think part of the problem is that you do not need to pack the widgets in the paned window - you have to add them.

Code: Select all

import tkinter as tk

root = tk.Tk()
root.title("Panes")
root.geometry("200x100")

panes = tk.PanedWindow(root,orient = "horizontal",showhandle = True)
panes.pack()

left = tk.Label(root,text = "Left")
right = tk.Label(root,text = "Right")

panes.add(left)
panes.add(right)

root.mainloop()
This does allow the panes to be resized but is only a start.

Re: tkinter panedWindow

Posted: Fri Sep 16, 2016 8:31 am
by RogerW
PanedWindow does not seem to be very well documented. I have not been able to find much on its correct use.

This slightly more elaborate version of my previous post might help.

Code: Select all

import tkinter as tk

# create main window
main = tk.Tk()
main.title("Panes")

# create a paned window and place it on the main window
paned = tk.PanedWindow(main,orient = tk.HORIZONTAL,showhandle = True,width = 200)
paned.grid()

# create two text boxes to go directly on the paned window 
left = tk.Label(main,text = "Left")
right = tk.Label(main,text = "Right")

# create a frame to contain two more text boxes
frame = tk.Frame(main)
upper = tk.Label(frame,text = "Upper")
lower = tk.Label(frame,text = "Lower")
upper.grid(row = 0)
lower.grid(row = 1)

# add the widgets to the pained window
# they will be set left to right
paned.add(left)
paned.add(frame)
paned.add(right)

# now start the program
main.mainloop()