开发者

How to Programmatically Delete Duplicate Records in a Tcl/Tk Treeview Widget

I have a treeview widget in my T开发者_如何学Pythoncl/Tk application that will often show duplicate records. I tried writing "lsort -unique" and "lrmdups" into my code to automatically delete the treeview duplicates, but with no luck. If possible, does anyone know how to do this?


If you are asking about the ttk::treeview widget that is provided with Tk 8.5 and above then one way to ensure unique entries is to be careful about the -id parameter. It will automatically prevent duplicate items with the same id:

% pack [ttk::treeview .tv -columns {One Two}] -fill both -expand 1
% .tv insert {} end -id id1 -text First -values {1st first}
id1
% .tv insert {} end -id id1 -text Second -values {2nd second}
Item id1 already exists


If you know the id of an item to delete, you can just do this:

.tv delete $id
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜