setting scrollbar in tkinter tree widget python

i am developing a small GUI application in tkinter python and i want to set horizontal and vertical scroll bars to a tree widget (only to tree widget not to main master window).but when i am trying to do so, there is no tree shown and in place of that only the small scrollbars are there. i know i am doing just a silly mistake. please help me in getting the issue resolved. here is my code:-

from Tkinter import *
import ttk
root = Tk()
root.minsize(width=1460, height=800)
root.maxsize(width=1460, height=800)
tree = ttk.Treeview(root)
columns = tree.column("#0", minwidth=0, width=400, stretch=True)   
tree.insert("" , 0,    text="Line 1")
id2 = tree.insert("", 1, "dir2", text="Dir 2")
tree.insert(id2, "end", "dir 2", text="sub dir 2")
scrollbar = Scrollbar(tree)
scrollbar.pack(side = RIGHT, fill=Y )  
scrollbar.config(command = tree.yview )
tree.pack()
root.mainloop()

Answers


The scrollbars need to have the root window as the parent, not the tree.

scrollbar = Scrollbar(root)

Need Your Help

Unable to send email from localhost using gmail smtp?

php email cakephp smtp gmail

I am looking into cakephp email component first time. I am sending email like this from my localhost: