Skip to main content
 首页 » 编程设计

python之重新打开文件时,将光标设置在与之前在 TreeView 中选择的位置相同的位置。

2025年05月04日10daizhj

在关闭该文件之前将光标设置在与在 TreeView 中选择的位置相同的位置,并且在重新打开文件时我想将该光标设置在相同的位置。我使用 pygtk 和 python 完成了这项工作。

请您参考如下方法:

last_path = treeview.get_cursor()[0] 
## do whatever you want, then finally: 
treeview.set_cursor(last_path) 
treeview.scroll_to_cell(last_path)