logo       

textview: how to insert characters?: msg#00005

gnome.gtk+.python

Subject: textview: how to insert characters?

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.

Thanks for help,
Riccardo

--
-=Riccardo Galli=-

_,e.
s~ ``
~@. ideralis Programs
. ol
`**~ http://www.sideralis.net
_______________________________________________
pygtk mailing list pygtk@xxxxxxxxxx
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise