我正在尝试用文本填充 SourceView 的缓冲区,然后滚动以使特定行可见,如下所示:
lines = '....'.split('\n')
line_number = 76 # For instance, assuming lines has at least this many lines
buffer = view.get_buffer()
for line in lines:
buffer.insert(end_iter, line + '\n')
iter = buffer.get_iter_at_line()
mark = buffer.get_mark('insert')
buffer.move_mark(mark, iter)
mark = buffer.get_mark('selection_bound')
buffer.move_mark(mark, iter)
view.scroll_to_mark(mark, 0.3, True, 0, 0.5)
这会滚动到缓冲区中或多或少的随机位置。我在这里做错了吗?或者这不起作用?