[pygtk] Interactive PyGTK shell that works on win32 as well

Felix Rabe (public) public at felixrabe.textdriven.com
Sat Aug 5 08:48:03 WST 2006


Hi,

Leandro Lameiro wrote:
 > lameiro at lameiro-laptop:~/Desktop/pygtk-shell$ ./shell.pyw
 > Traceback (most recent call last):
 >   File "/home/lameiro/Desktop/pygtk-shell/pygsh/key_binder.py", line 36,
 > in __getattr__
 >     return getattr(self.gdk, name + "_MASK")
 > AttributeError: 'module' object has no attribute 'F11_MASK'

The "module" here is gtk.keysyms.  What my code tries to do is find 
gtk.keysyms.F11 first (which should exist), then gtk.gdk.F11_MASK (which 
doesn't).

I don't have PyGTK 2.9 installed, but I don't see why the keysyms should 
be any different between 2.8 and 2.9.  CVS still includes F11.

See: http://cvs.gnome.org/viewcvs/pygtk/gtk/keysyms.py?view=markup

What do you get when you execute the following?

 >>> import gtk
 >>> print "\n".join(filter(lambda x: x[0] == "F", dir(gtk.keysyms)))

Also, try again by replacing the Keys class in pygsh/key_binder.py with 
the following:

=====

class Keys(object):

     def __getattr__(self, name):
         keyval = getattr(gtk.keysyms, name, None)
         if keyval is not None: return keyval
         return getattr(gtk.gdk, name + "_MASK")

     __getitem__ = __getattr__

=====

I don't really expect it to work for you, so then the last resort is to 
comment out line 44 (the one binding the F11 key) and try again.

Greetings,
Felix


More information about the pygtk mailing list