The selected row keeps on deselect when the new value is updated in that position. Can we just keep the selection fixed even when the row value changes. Please have a look at the sample code given below, where a treeview row are getting updated every second but as the value gets updated, the row automatically deselects. Please help me with the idea to get the selection fixed even when the value changes. Thank you.

from tkinter import ttk
import tkinter
import threading

def main():
    root = tkinter.Tk()

    ccols = ('num1','num2')
    treeview = ttk.Treeview(root, columns=ccols)
    for col in ccols:
        treeview.heading(col, text=col)
    treeview.grid(row=8, column=0)

    def sample():
       for i in range(100):
           treeview.delete(*treeview.get_children()) 
           treeview.insert("","end",values=(i,0))

       threading.Timer(1.0, sample).start()

    sample()
    root.mainloop()


if __name__ == '__main__':

main()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.