Tk treeview column sort

后端 未结 5 2083
旧巷少年郎
旧巷少年郎 2020-11-30 05:26

Is there a way to sort the entries in a Tk Treeview by clicking the column? Surprisingly, I could not find any documentation/tutorial for this.

5条回答
  •  迷失自我
    2020-11-30 05:49

    This did not work in python3. Since the Variable was passed by reference, all lambdas ended up refering to the same, last, element in columns.

    This did the trick for me:

    for col in columns:
        treeview.heading(col, text=col, command=lambda _col=col: \
                         treeview_sort_column(treeview, _col, False))
    

提交回复
热议问题