[Tutor] [pygtk] key_press_event

John CORRY john.corry at ntlworld.com
Sun Aug 13 12:47:05 CEST 2006


Sandro,

That's exactly what I need.  

Thanks,

John.

>     def callback3(self,data,widget):
>         
>         input = data.get_text()
>         print input
>         data.set_text("test")


If you don't return True, default callback will be called that insert
the 'a'.

I have something like this:

    def digits_check_input_cb(self, widget, event):
        """prevents the possibility of inputting wrong chars"""
        ## fixme: missing comma, and cut&paste
        key = gtk.gdk.keyval_name (event.keyval)

 
ONLYDIGITS="([0-9.,]|BackSpace|Left|Right|F1|period|Tab|Up|Down)"
        if not re.match (ONLYDIGITS, key):
            return True

Not sure whether this is the best way thought...

sandro
*;-)

-- 
Sandro Dentella  *:-)
http://www.tksql.org                    TkSQL Home page - My GPL work




More information about the Tutor mailing list