Hi all,

I am currently learning PyGTK and got stuck on the following problem:

I have myentry = gtk.Entry() containing an integer (actually a string,
of course, but int(myentry.get_text()) works) and want to increase this
integer by one if the button '+' is pressed.

Here's what I tried:

myentry.connect('key-press-event', increase)

def increase(entry, event):
        if event.keyval == gtk.keysyms.plus:
                mynumber = int(entry.get_text())
                mynumber += 1
                entry.set_text(str(mynumber))

This works at first, but the '+' is inserted into the text entry after
the number was increased. Do you have an idea how to prevent this?

A related problem is covered in the FAQ at

http://faq.pygtk.org/index.py?req=show&file=faq14.005.htp

but I was not able to modify this (outdated ?) code to my needs :-(

Thanks a lot for your help,

Eike
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to