Hi list,

I was wondering if it's possible to use the 'Up', 'Down', 'Left', and
'Right' keys as accelerators in AccelGroup.

I'm led to believe one can't, as the short snippet below fails to call
the blop() method when 'Up' is pressed, whereas pressing 'b' does
succesfully call blip().

Is there any workaround ?

Thanks for your time,

- Pierre


# Here's the code.

import gtk

class CustomWindow(gtk.Window):

     def __init__(self):
         gtk.Window.__init__(self)
         self.uimanager = self._make_ui_manager()
         accelgroup = self.uimanager.get_accel_group()
         self.add_accel_group(accelgroup)
         self.drawing_area = gtk.DrawingArea()
         self.add(self.drawing_area)
         self.connect("delete-event", gtk.main_quit)
         self.show_all()

     def _make_ui_manager(self):
         ui = '''\
             <ui>
                 <accelerator action='Blip'/>
                 <accelerator action='Blop'/>
             </ui>'''
         uimanager = gtk.UIManager()
         uimanager.add_ui_from_string(ui)
         actions = [('Blip', None, None, 'b', '', self.blip),
                    ('Blop', None, None, 'Up', '', self.blop)]
         actiongroup = gtk.ActionGroup('')
         actiongroup.add_actions(actions)
         uimanager.insert_action_group(actiongroup, 0)
         return uimanager

     def blip(self, *args):
         print 'Blip!'

     def blop(self, *args):
         print 'Blop!'


win = CustomWindow()
win.resize(300, 300)
gtk.main()



_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to