[pygtk] problems with ctrl keybindings

Bryan Feir jenora at sympatico.ca
Fri Mar 16 23:34:27 WST 2007


On Fri, Mar 16, 2007 at 08:54:28AM +0100, Thomas Guettler wrote:
> Am Donnerstag, 15. M?rz 2007 18:34 schrieb Fabian Braennstroem:
> > Hi,
> >
> > I have some own keybindings for my filemanager, which work pretty
> > well. Except combinations with the 'Control' key make problems (but
> >         if (keyname == "l" and event.state == gtk.gdk.CONTROL_MASK):
> > 	   'do_something'
> 
> Hi,
> 
> I guess yo need to use & instead of ==

   Yes.  Specifically the problem is that if you use '==', then the
match won't work if you have any other modifier keys active, including
NumLock.  Which could be why it seemed to work before but not now.  So
you need to check only those state bits that you require.  If you need
to match Control but not Shift, for example, then it would be something
like:
 (event.state & (gtk.gdk.CONTROL_MASK|gtk.gdk.SHIFT_MASK)) ==
   gtk.gdk.CONTROLMASK

---------------------------+---------------------------------------------------
Bryan Feir           VA3GBF|"The professor holds the keys to the gates of
Home:jenora at sympatico.ca   | knowledge; not to let the student in, but to let
                           | him get out and on to better things." -- Leacock
---------------------------+---------------------------------------------------


More information about the pygtk mailing list