[pygtk] Simple key binding

Antoine Martin antoine at nagafix.co.uk
Mon Aug 16 20:35:18 WST 2010


  On 08/16/2010 12:58 PM, chaouche yacine wrote:
> Hello,
>
> I want my application to quit when I press ctrl-q. I don't want to have menus. What is the simplest way to do this ? what is the best way to do this ?
>
> My code is as simple as :
>
> <code>
> import pygtk
> pygtk.require("2.0")
> import gtk
>
> w = gtk.Window()
accel_group = gtk.AccelGroup()
accel_group.connect_group(ord('q'), gtk.gdk.CONTROL_MASK, 
gtk.ACCEL_LOCKED, gtk.main_quit)
w.add_accel_group(accel_group)

(untested)
> w.show()
> gtk.main()
> </code>
>
> What should I add to this code to make it happen ?
>
> Thank you for you help.
>
>
> Y.Chaouche
>
>
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/



More information about the pygtk mailing list