[pygtk] Entry.connect_after('changed', ...) doesn't see updated cursor position

Gian Mario Tagliaretti gianmt at gnome.org
Tue Dec 30 23:59:06 WST 2008


On Tue, Dec 30, 2008 at 12:49 PM, Yang Zhang <yanghatespam a gmail.com> wrote:

Hi Yang,

> Hi, I have a signal handler connected to an Entry's 'changed' signal,

use the "insert-text" instead:

import gtk

def on_change(widget, new_text, new_text_length, position):
    print 'inserted text = ', new_text
    print 'inserted text len = ', new_text_length
    print 'cursor position = ', widget.get_position()

w = gtk.Window()
w.connect("destroy", gtk.main_quit)

b = gtk.Entry()

b.connect("insert-text", on_change)

w.add(b)
w.show_all()

gtk.main()

cheers
-- 
Gian Mario Tagliaretti
GNOME Foundation member
gianmt a gnome.org


More information about the pygtk mailing list