[pygtk] increase number in gtk.entry by pressing '+'
Eike Nicklas
lists at ephys.de
Fri Jan 11 17:33:32 WST 2008
On Wed, 09 Jan 2008 22:04:24 -0300 Germán Poó-Caamaño wrote:
> El jue, 10-01-2008 a las 00:23 +0100, Eike Nicklas escribió:
> >
> > 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 :-(
>
> Yep. The sample code looks outdated.
>
> Attached the sample fixed. It would help you to do what you want.
>
Thanks a lot for the updated version! That helped me a lot and I got it
working now. I basically just replaced the insert function with:
def insert(widget, text, pos):
weight = float(widget.get_text())
weight += 1
widget.handler_block(insert_sig)
widget.set_text(str(weight)
widget.handler_unblock(insert_sig)
The only minor problem remaining was, that if the text in the entry is
selected, the selection gets deleted/replaced on any key press. My first
workaound is to prevent the default test selection when focusing on the
entry (with TAB, for examplse) with:
entry.connect('focus-in-event', on_focus)
def on_focus(entry, event):
gobject.idle_add(entry.set_position, 0)
That seems to me like a quick hack, are there any better solutions?
Thanks again,
Eike
More information about the pygtk
mailing list