Python Forum
[Tkinter] Justify the treeview to the last entry
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Justify the treeview to the last entry
#7
Use see(item) to see an item
import tkinter as tk
import tkinter.ttk as ttk

def bud():
    i = len(leafs)
    leafs.append(tree.insert('', tk.END, values=(i, i**2)))
    tree.see(leafs[-1])

leafs = []
root = tk.Tk()
tree_frame = tk.Frame(root)
tree_frame.pack()

tree = ttk.Treeview(tree_frame, columns=('A', 'A2'), height=5)
tree.heading('A', text='A', anchor='center')
tree.heading('A2', text='A**2', anchor='center')
tree.pack(side=tk.LEFT)

yscroll = ttk.Scrollbar(tree_frame,  orient=tk.VERTICAL, command=tree.yview)
yscroll.pack(side=tk.LEFT, fill='y')
tree.configure(yscroll=yscroll.set) 

tk.Button(root, text='Push Me', command=bud).pack()
root.mainloop()
MrP likes this post
Reply


Messages In This Thread
Justify the treeview to the last entry - by MrP - Feb-26-2021, 11:42 PM
RE: Justify the treeview to the last entry - by MrP - Feb-28-2021, 12:19 PM
RE: Justify the treeview to the last entry - by MrP - Feb-28-2021, 04:25 PM
RE: Justify the treeview to the last entry - by MrP - Mar-01-2021, 01:44 AM
RE: Justify the treeview to the last entry - by deanhystad - Mar-01-2021, 05:43 AM
RE: Justify the treeview to the last entry - by MrP - Mar-01-2021, 11:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] [split] Is there a way to embed a treeview as a row inside another treeview? CyKlop 5 3,486 Oct-20-2021, 12:14 AM
Last Post: CyKlop
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,528 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] Not getting entry values on button click & treeview not updating ? swanysto 4 7,154 May-10-2019, 04:16 PM
Last Post: swanysto
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 3,556 Mar-18-2019, 05:36 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020