in my application I have several TextViews aligned in a grid horizontally. They all scroll syncronous (to my surprise) this works automatically.
Now i want at a certain keyboard shortcut, to jump the cursor to a line number and select the line. This also works. What does not work is to scroll to this line. My code looks like this:
# to sequence view to class self.parent.parent.window.stack.set_visible_child_name("sequence") nb.switch_to_tab(class_name) # focus tab = nb.get_tab(class_name) tv = tab.sequenceTextView tv.grab_focus() # set postion in textfield buf = tab.sequenceBuf cursor = buf.get_iter_at_line(position) res = tv.scroll_to_iter(cursor, 0.0, True, 0.5, 0.5) buf.place_cursor(cursor) # select line line_begin = buf.get_iter_at_line(position) # again, since forward_to_line does not return a copy cursor.forward_to_line_end() buf.select_range(line_begin, cursor) # scroll tv.scroll_mark_onscreen(buf.get_insert())
Except to the last line everything works fine.
I tried virtually anything: scroll to an iter, scroll the first textview added to the grid, scroll to cursor.
Also I get no warning which helps. With the (test) line
res = tv.scroll_to_iter(cursor, 0.0, True, 0.5, 0.5)
above, I got as return code False, which is indeed correct. But I still can’t figure out, why.
Thanks in advance!