Python Tkinter Treeview - 如何确定是否显示最后一个 child?
Python Tkinter Treeview - How do I determine if the last child is displayed?
我创建了一个树视图来显示收到的消息。由于收到的消息数量超过了树视图的大小window,我使用这行代码
self.logTree.yview_moveto(1)
以确保最新消息始终显示在 window 的底部。但是,如果用户向上滚动,我想停止这种行为。我需要一种方法来确定是否显示最后收到的消息。我该怎么做?
谢谢
您可以使用 bbox()
检查 Treeview
的项目是否可见:
# get the iid of last item
last = tree.get_children()[-1]
# bbox() returns the bounding box of the item if it is visible
# otherwise it returns empty string
visible = tree.bbox(last) != ""
我创建了一个树视图来显示收到的消息。由于收到的消息数量超过了树视图的大小window,我使用这行代码
self.logTree.yview_moveto(1)
以确保最新消息始终显示在 window 的底部。但是,如果用户向上滚动,我想停止这种行为。我需要一种方法来确定是否显示最后收到的消息。我该怎么做?
谢谢
您可以使用 bbox()
检查 Treeview
的项目是否可见:
# get the iid of last item
last = tree.get_children()[-1]
# bbox() returns the bounding box of the item if it is visible
# otherwise it returns empty string
visible = tree.bbox(last) != ""