pythonpygtkgtktextviewgtkscrolledwindow

scroll TextView in ScrolledWindow so that cursor is visible in pyGTK2


I have a Textview in a ScrolledWindow. I have set up a callback on signal "changed" of textbuffer of the textview. Now I need to scroll the ScrolledWindow to the point of the cursor. How do I do that?

self.outgoing = gtk.ScrolledWindow()
self.outgoing.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.textview = gtk.TextView()
textbuffer=self.textview.get_buffer()
textbuffer.connect("changed",self.scrolltocursor)
self.outgoing.add_with_viewport(self.textview)

def scrolltocursor(self,text_buffer):
    <I don't know what to do here>

Help please.


Solution

  • Well it seems the problem was that I did add_with_viewport to put the textview in the scrolled window. Now I tried self.outgoing.add(self.textview) and it works without any callbacks to change. So yeah. That fixes it.