[pygtk] key_press_event

Sandro Dentella sandro at e-den.it
Sun Aug 13 18:27:44 WST 2006


>     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 pygtk mailing list