GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Apr 19, 2014 1:49 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Invalid text buffer iterator
PostPosted: Thu Jun 27, 2013 6:11 pm 
Offline

Joined: Thu Jun 27, 2013 3:25 pm
Posts: 2
Hi,

the following code is supposed to automatically insert linebreaks every 60 characters in a TextBuffer.
I can't figure out, why I'm getting "Gtk-WARNING **: Invalid text buffer iterator", even though I'm reinitializing
the iter using get_iter_at_offset.



Code:
def get_line(self, start_iter):
  end_iter = start_iter.copy()
  end_iter.forward_to_line_end()
  return str(start_iter.get_text(end_iter))

line_iter = self.buffer.get_start_iter()
while True:
  line = self.get_line(line_iter)
  if self.binary_mode and len(line) > 60:
    offset = line_iter.get_offset()
    line_iter.forward_chars(60)
    self.buffer.insert(line_iter, '\n')
    line_iter = self.buffer.get_iter_at_offset(offset)
 
  if not line_iter.forward_line():
    break


Top
 Profile  
 
 Post subject: Re: Invalid text buffer iterator
PostPosted: Thu Jun 27, 2013 6:42 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Hello,

Without knowing what language or version of GTK+ you are using it is difficult to give a full answer. Also where in your source did the error occur? By running a debugger you could find what caused the error and then trace back to correct it.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Invalid text buffer iterator
PostPosted: Thu Jun 27, 2013 6:54 pm 
Offline

Joined: Thu Jun 27, 2013 3:25 pm
Posts: 2
Good point ;)

I'm running pygtk on python2, I beleive the gtk version is 3.x (import from gi.repository)

The error occurs upon calling:

"if not line_iter.forward_line():"


Top
 Profile  
 
 Post subject: Re: Invalid text buffer iterator
PostPosted: Fri Jun 28, 2013 12:42 pm 
Offline
Familiar Face

Joined: Wed Jun 05, 2013 7:39 am
Posts: 6
Location: France
Hello,

It is not possible to use both PyGTK and PyGI (gi.repository).
If you really import both of them (pygtk (or just gtk) and Gtk from gi.repository), that can lead to unpredictable behaviour I believe...
You should first check this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group