Hi all, during the filling of a ttk.Treeview, widget I want to temporarily disable the <<TreeviewSelect>> (to restore the previously selected items), and re-enable it at the end. However, when I unbind the <<TreeviewSelect>> event the messages are still send. See the following demo code. I would expect that during the filling no <<TreeviewSelect>> message will be send, however I get hundreds of messages at the end
import tkinter as tk from tkinter import ttk def tvselect(event): print("SELECTION CHANGED") def fill(event=None): t.unbind("<<TreeviewSelect>>") for i in range(1000): item = t.insert("",tk.END,text=f"Item {i}") if i&1==0: t.selection_add(item) t.bind("<<TreeviewSelect>>", tvselect) if __name__ == "__main__": root = tk.Tk() t = ttk.Treeview(root) t.bind("<<TreeviewSelect>>", tvselect) t.pack(expand=tk.YES,fill=tk.BOTH) b = tk.Button(root, text="Press me", command=fill) b.pack() root.mainloop()
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss