Hi,

Much more than the subject, I cannot explain well, so I'll let the code 
do the talking:
<code>
        self.accel_group = gtk.AccelGroup()
        self.main_window.add_accel_group(self.accel_group)

        gtk.accel_map_add_entry("<Virtaal>/Edit/Undo", gtk.keysyms.z, 
gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<Virtaal>/Edit/Search", gtk.keysyms.F3, 0)
        gtk.accel_map_add_entry("<Virtaal>/Navigation/Up", 
gtk.keysyms.Up, gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<Virtaal>/Navigation/Down", 
gtk.keysyms.Down, gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<Virtaal>/Navigation/PgUp", 
gtk.keysyms.Page_Up, gdk.CONTROL_MASK)
        gtk.accel_map_add_entry("<Virtaal>/Navigation/PgDown", 
gtk.keysyms.Page_Down, gdk.CONTROL_MASK)

        self.accel_group.connect_by_path("<Virtaal>/Edit/Undo", 
self._on_undo)
        self.accel_group.connect_by_path("<Virtaal>/Edit/Search", 
self._on_search)
</code>

This, in its own, works fine, but then I added "Edit" and "Navigation" 
menu's via Glade and added the following code directly below the block 
above (self.gui is the Glade.XML object):
<code>
        # gtk.Menu's:
        self.gui.get_widget('menu_edit').set_accel_group(self.accel_group)
        
self.gui.get_widget('menu_navigation').set_accel_group(self.accel_group)

        # gtk.MenuItems:
        
self.gui.get_widget('mnu_undo').set_accel_path("<Virtaal>/Edit/Undo")
        
self.gui.get_widget('mnu_search').set_accel_path("<Virtaal>/Edit/Search")
        
self.gui.get_widget('mnu_up').set_accel_path("<Virtaal>/Navigation/Up")
        
self.gui.get_widget('mnu_down').set_accel_path("<Virtaal>/Navigation/Down")
        
self.gui.get_widget('mnu_page_up').set_accel_path("<Virtaal>/Navigation/PgUp")
        
self.gui.get_widget('mnu_page_down').set_accel_path("<Virtaal>/Navigation/PgDown")
</code>

The accelerators still work, but the menu items, once activated, does 
nothing, even though the correct keyboard shortcuts are displayed in the 
menu's. I realize that only "Undo" and "Search" have handlers defined in 
the given snippets, but even they do not work.

I guess my question is how to use the already-connected accelerator 
handlers (self._on_undo and self._on_search) when the related menu item 
is activated.

Thanks in advance.

Regards,

-- 
Walter Leibbrandt                  http://translate.org.za/blogs/walter
Software Developer                                  +27 12 460 1095 (w)
Translate.org.za

Recent blogs:
* The first official release of Spelt
http://www.translate.org.za/blogs/walter/en/content/first-official-release-spelt
* Auto-completion and auto-correction for Gtk+ widgets
* Gtk+ Tip of the Day: Modifying the subject of an event being processed


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

Reply via email to