Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top