[pygtk] event handling

Pascal DUCHATELLE pduchatelle at yahoo.fr
Mon Sep 4 18:42:23 WST 2006



"David M. Cook" <dave at davidcook.org> a écrit : On Sun, Sep 03, 2006 at 08:37:13AM +0200, Pascal DUCHATELLE wrote:
>          dic = {"on_mainWindow_destroy" : gtk.main_quit,
>                 "on_hello_key_press_event" : self.hellorecompile}
>  followed by this:
>          self.wTree.signal_autoconnect(dic)
>  Is there a way to use the second solution but also pass 
>  an argument like in the first one ?

You can use a tuple in your dic.  See

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq22.004.htp

Also, you can use a closure:

foo = 5
baz = 6
def my_handler(*args):
    print foo
    print baz
    
dic = {"some_handle" : my_handler}

Dave Cook
_______________________________________________
pygtk mailing list   pygtk at daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Hi Dave,
I will turn my question differently: in your answer your my_handler accepts keywords. Then how do you pass them to your my_handler in the dic since using a coma as separator is considered to be followed by the next dic key-entry pair. Maybe I'm wrong. Or is a tuple or a list OK as an entry in such a dictionary ?
Thank you
Pascal

 		
---------------------------------
 Découvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet ! Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et vos expériences. Cliquez ici. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20060904/5e820266/attachment.htm


More information about the pygtk mailing list