0

I am trying to make a GUI using tkinter. How can i have 3 treeviews - two on the top side by side and third on the bottom below the two treeviews on the top. I managed to get 2 side by side. I provided the side value as left for the first two but when I use bottom for the third it comes in the middle of the previous two treeviews.

container = ttk.Frame()
container.pack(fill='both', expand=True, side=side)
self.tree = ttk.Treeview()

Thanks for the help

1 Answer 1

5

When you put upper-left and upper-right tree view widget, pack with side=LEFT to make them packed from left to right. (You can also use side=RIGHT if you pack right one first).

Beside that, pack from top to bottom. (pack with side=TOP or omit side)

from Tkinter import *
import ttk

# In Python 3.x
#from tkinter import *
#from tkinter import ttk

root = Tk()

upper_container = Frame(root)
upper_container.pack()

left_tree = ttk.Treeview(upper_container)
left_tree.pack(side=LEFT)
right_tree = ttk.Treeview(upper_container)
right_tree.pack(side=LEFT)

lower_tree = ttk.Treeview(root)
lower_tree.pack()

root.mainloop()

enter image description here

UPDATE

updated version that will allow user to resize upper / lower area using PanedWindow.

from Tkinter import *
import ttk

# In Python 3.x
#from tkinter import *
#from tkinter import ttk

root = Tk()

pane = PanedWindow(orient=VERTICAL)
pane.pack()

upper_container = Frame(pane)
upper_container.pack()

left_tree = ttk.Treeview(upper_container)
left_tree.pack(side=LEFT)
right_tree = ttk.Treeview(upper_container)
right_tree.pack(side=LEFT)

lower_tree = ttk.Treeview(pane)
lower_tree.pack()

pane.add(upper_container)
pane.add(lower_tree)

root.mainloop()
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the quick reply. Just one more thing. How can I make it such that we can manually resize each individual treeviews on the GUI.
@PottaPitot, Sorry, I don't know about it. How about search question or post a separated question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.