As in topic I have TextView() and TextBuffer() added to it, I also have Tags created so when I select text and click button it will make text BOLD or something. Up to this point all works well, now I need to be able to go through all text in TextView and find what Tag is applied and where, I need this so I can format text by adding stuff before and after tagged text.
here is part of the code:
self.textview = Gtk.TextView()
self.buffer = self.textview.get_buffer()
self.scrolledwindow.add(self.textview)
self.textview.show()
self.tag_bold = self.buffer.create_tag("bold", weight=Pango.Weight.BOLD)
It would be best if I could get output like, "test text" is "bold".
Thanks for any help.
EDIT Here's the correct function to use:
Gtk.TextIter.forward_to_tag_toggle()
here's an example that generates a list of all bolded words:
While you are using pygi (not pyGTK; note the uppercase Gtk in your functions), many of the pyGTK functions are still valid though may require some tweaking. You can get documentation here for gtk.textiter in pygtk.
OLD ANSWER: Not sure if this is the optimal way, but I found that you could iterate over each character (maybe each word if you want) and test whether the character has the tag you want: Here's a simple function to do that:
you can also use the Gtk.TextIter get_tags() method to get what tags a character has.
Finally, what may work better is to store the bounds in some list when you apply the tags to begin with.