Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtk: How can I get a part of a file in a textview with scrollbars relating to the full file

Tags:

python

pygtk

gtk

I'm trying to make a very large file editor (where the editor only stores a part of the buffer in memory at a time), but I'm stuck while building my textview object. Basically- I know that I have to be able to update the text view buffer dynamically, and I don't know hot to get the scrollbars to relate to the full file while the textview contains only a small buffer of the file.

I've played with Gtk.Adjustment on a Gtk.ScrolledWindow and ScrollBars, but though I can extend the range of the scrollbars, they still apply to the range of the buffer and not the filesize (which I try to set via Gtk.Adjustment parameters) when I load into textview. I need to have a widget that "knows" that it is looking at a part of a file, and can load/unload buffers as necessary to view different parts of the file. So far, I believe I'll respond to the "change_view" to calculate when I'm off, or about to be off the current buffer and need to load the next, but I don't know how to get the scrollbars to have the top relate to the beginning of the file, and the bottom relate to the end of the file, rather than to the loaded buffer in textview.

Any help would be greatly appreciated, thanks!

like image 379
user324181 Avatar asked Nov 14 '22 11:11

user324181


1 Answers

You probably should create your own Gtk.TextBuffer implementation, as the default one relies on storing whole buffer in memory.

like image 139
el.pescado - нет войне Avatar answered Dec 27 '22 09:12

el.pescado - нет войне