Tkinter ScrolledText,如何在将光标移动到给定行时自动更新滚动条?

Tkinter ScrolledText, how to automatically update the scrollbar when moving cursor to a given line?

我有一个 Tkinter ScrolledText 填充了 100 行文本:

import tkinter, tkinter.scrolledtext
root = tkinter.Tk('test')
text = tkinter.scrolledtext.ScrolledText(master=root, wrap='none')
text.pack(side="top", fill="both", expand=True, padx=0, pady=0)
text.insert(tkinter.END, ''.join("hello%i\n" % i for i in range(100)))
text.mark_set("insert", "1.1")  # cursor position at the start
text.focus()
root.mainloop()

当光标移动到第50行时:

text.mark_set("insert", "50.1")

光标确实移动到那里,但滚动条没有相应更新。

问题:如何在光标位置移动到第n行时自动更新滚动条位置?

文本小部件有一个名为 see 的方法,它将滚动到给定的索引。

text.mark_set("insert", "50.1")
text.see("insert")

来自规范 tcl/tk 文档:

Adjusts the view in the window so that the character given by index is completely visible. If index is already visible then the command does nothing. If index is a short distance out of view, the command adjusts the view just enough to make index visible at the edge of the window. If index is far out of view, then the command centers index in the window.