[pygtk] textview: how to insert characters?
Riccardo Galli
riccardo_togli.questo at e.questo_sideralis.net
Sat Aug 2 11:59:00 EDT 2003
Hello world.
I'm trying to insert characters in a textview, in a position different
from the one where's the cursor.
I'm alwais getting this warning:
Gtk-WARNING **: Invalid text buffer iterator: either the iterator is
uninitialized, or the characters/pixbufs/widgets in the buffer have
been modified since the iterator was created.[...]
This a simple example code, of a method called on insert_text event .
When 6 characters are typed,it tries to put an 'X' in the second cursor
position, and then to put the cursor where it was before.
def on_insert_text(self,buffer,textIter,char,*args):
buffer.disconnect(self.signal_id)
if textIter.get_chars_in_line()==6 :
newIter=buffer.get_iter_at_offset(2)
buffer.insert(newIter,'X')
buffer.place_cursor(buffer.get_end_iter())
self.signal_id=buffer.connect('insert-text',self.on_insert_text)
I understand from the warning that I should use marks, but
I don't know how.
I've posted this msg to pygtk list too.
Thanks for help,
Riccardo
--
-=Riccardo Galli=-
_,e.
s~ ``
~@. ideralis Programs
. ol
`**~ http://www.sideralis.net
More information about the Python-list
mailing list