python - How to refresh tkinter entry value? I get a 1-click lag -
i built interface user fills hierarchical form. past values displayed in ttk.treeview
. allow user edit previous values clicking on tree. value gets filled on form can edited , overwriten.
the problem: value insert on entry
widget displayed next time user clicks it, 1 click lagging. please run sample code better understanding. gets confusing because if user clicks value , another, display clicked value.
it must have event handling routine in tkinter, not find , answer. how can rid of lag?
import tkinter tk tkinter import ttk root = tk.tk() def cb_clique(event): item = tree.selection()[0] entry1.delete(0, "end") entry1.insert(0, item) entry1 = tk.entry(root, width=15) entry1.grid(row=1,column=1) tree = ttk.treeview(root) tree.bind("<button-1>", cb_clique) tree["columns"]=("valor") tree.column("valor", width=200 ) tree.heading("valor", text="valor") tree.grid(row=3, column = 1, columnspan = 4) tree.insert("", "end", iid = "will display position",text = "click me", values=("a","b")) tree.insert("", "end", iid = "use position info", text = "click me", values=("a","b")) root.mainloop()
looks <button-1>
event triggers before window notices selection has changed, selection()
returns thing selected before click. try changing event binding <<treeviewselect>>
.
tree.bind("<<treeviewselect>>", cb_clique)
Comments
Post a Comment