Need Example/help With Gtktextbuffer (of Gtktextview) Serialize/deserialize
Solution 1:
If you need to save the tags because you just want to copy the text into another text buffer, you can use gtk.TextBuffer.insert_range()
.
If you need to save the text with tags into another format readable by other programs, I once wrote a library with a GTK text buffer serializer to and from RTF. It doesn't have any Python bindings though. But in any case the code is a good example of how to use the serializer facility. Link: Osxcart
Solution 2:
I haven't worked with GtkTextBuffer's serialization. Reading the documentation you linked, I would suggest trying the default serializer, by calling
textbuffer.register_serialize_tagset()
This gives you GTK+'s built-in proprietary serializer. Being proprietary here means that it doesn't serialize into some well-known format; but if all you need is the ability to save out the text buffer's contents and load them back, this should be fine.
Of course the source code is available inside GTK+ if you really want to figure out how it works; I would recommend against trying to implement e.g. a stand-alone de-serializer though, since there are probably no guarantees made by GTK+ that the format will remain as-is.
Post a Comment for "Need Example/help With Gtktextbuffer (of Gtktextview) Serialize/deserialize"