Feb-26-2021, 11:42 PM
Thankyou in advance for any assistance...
I have a ttk.Treeview that is populated from a sqlite3 database, it has a vertical scrollbar, the scrollbar scrolls from the first record to the last record with no problem. What I would like to happen is when a new record is added I want the treeview to show the newest record at the bottom of the table without grabbing the scollbar and moving it manually to reveal the latest record. I have tried (tree.yview_moveto(1)) also (tree.yview_moveto(1.0)) also (tree1.configure(tree.yview_moveto(1))). I have placed these in the function that that populates the treeview and they do nothing and they do not create any errors. I believe it has to be something simple that I am overlooking
I have a ttk.Treeview that is populated from a sqlite3 database, it has a vertical scrollbar, the scrollbar scrolls from the first record to the last record with no problem. What I would like to happen is when a new record is added I want the treeview to show the newest record at the bottom of the table without grabbing the scollbar and moving it manually to reveal the latest record. I have tried (tree.yview_moveto(1)) also (tree.yview_moveto(1.0)) also (tree1.configure(tree.yview_moveto(1))). I have placed these in the function that that populates the treeview and they do nothing and they do not create any errors. I believe it has to be something simple that I am overlooking
def DisplayData():
conn = sqlite3.connect("service.db")
cur = conn.cursor()
cur.execute("SELECT * FROM ticket")
result = cur.fetchall()
if len(result) !=0:
tree1.delete(*tree1.get_children())
for row in result:
tree1.insert('', tk.END, values=row)
tree1.yview_moveto(1.0) # not doing anything and neither does the following 2 lines
#tree1.configure(tree1.yview_moveto(1.0))
#tree1.yview("moveto", 1)
#conn.commit()
conn.close()
# this hilites the last entry but does not scroll to the focused line
#tree1_count = tree1.get_children()[-1]
#tree1.selection_set(tree1_count)
#tree1.focus(tree1_count)
return
