简体   繁体   中英

PyGTK: gtk.TextView.scroll_to_mark doesn't update display for large files

My application has a gtk.TextView (actually gtksourceview.View) widget that displays a (large) text file and is indexed by a TreeView. Double-clicking an entry in the TreeView jumps to a corresponding spot in the TextView, which involves this method:

def jump_to_line(self, startline):
    itr = self.buffer.get_iter_at_line(startline)
    mark = self.buffer.create_mark(None, itr, True)
    self.scroll_to_mark(mark, 0.0, use_align=True, yalign=0.0)

self is my widget, which is a subclass of TreeView, and self.buffer is obviously the corresponding gtk.TextBuffer. startline here is an integer denoting which line to jump to. The issue is that when I test with "large" files (less than 1 MB), this works as expected, but with a "really large" (> 10 MB), the jump doesn't occur until I click on the widget, at which point it updates. I have no idea why it can't scroll automatically for larger files. Is there something I'm not aware of here?

通过使用self.scroll_to_iter解决。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM