[Python] Python Tkinter treview: column size does not expand to window height

Discussão em 'Python' iniciado por Stack, Agosto 21, 2025.

  1. Stack

    Stack Membro Participativo

    I am unable to make the treeview widget on Tkinter fill the whole column. I tried it using column configure with weight but it does not work. When I run it, the treeview displays it as given in the link to the pic. How can i get the treeview to display the directories which fill the window right down to the bottom.

    class dir_tree(object):
    def __init__(self, master, path):
    self.nodes = dict()
    frame = tk.Frame(master)
    self.tree = ttk.Treeview(frame)

    ysb = ttk.Scrollbar(frame, orient='vertical', command=self.tree.yview)
    xsb = ttk.Scrollbar(frame,orient='horizontal',command=self.tree.xview)
    self.tree.configure( xscroll=master.winfo_screenheight())
    self.tree.heading('#0', text='Manga Directory', anchor='w')
    self.tree.grid(column = 0, sticky = 'ns')
    ysb.grid(row=0, column=1, sticky='ns')
    xsb.grid(row=1, column=0, sticky='ew')
    frame.grid(column = 0, sticky = 'ns')

    self.tree.columnconfigure(0, weight=1)
    abspath = os.path.abspath('/home/user/Desktop/')
    self.insert_node('', abspath, abspath)
    self.tree.bind('<<TreeviewOpen>>', self.open_node)

    def insert_node(self, parent, text, abspath):
    node = self.tree.insert(parent, 'end', text=text, open=False)
    if os.path.isdir(abspath):
    self.nodes[node] = abspath
    self.tree.insert(node, 'end')

    def open_node(self, event):
    node = self.tree.focus()
    abspath = self.nodes.pop(node, None)
    if abspath:
    self.tree.delete(self.tree.get_children(node))
    for p in os.listdir(abspath):
    self.insert_node(node, p, os.path.join(abspath, p))

    if __name__ == "__main__":
    dirr = dir_tree(root, path='/home/user/Desktop/')


    IMAGE

    [​IMG]
    How can i make the vertical scrollbar fill over the whole window height in left rather than only a part of window as shown?

    Continue reading...

Compartilhe esta Página