[pygtk] Popup menu and accelerators

Danny Milosavljevic danny.milo at gmx.net
Fri Mar 31 01:59:41 WST 2006


Hi,

Am Donnerstag, den 30.03.2006, 10:39 +0200 schrieb Sebastian Pölsterl:
> John Finlay wrote:
> > Sebastian Pölsterl wrote:
> >> Hi!
> >>
> >> I generate a popup menu with gtk.UIManager and want to add accellerators
> >> to the menu's items. If I press one of the key combinations the right
> >> function will be called, but the popup menu itsself doesn't show the
> >> combination next to the item. In the end it should look like
> >> http://developer.gnome.org/projects/gup/hig/2.0/images/file-menu.png
> >> But currently, Ctrl+N etc. on the right are missing.
> >>
> >> Here is my code:
> >>        [...]
> >>
> >>
> > Try adding the accelerators when adding actions to the actiongroup, for
> > example:
> >
> >        self.actiongroup.add_actions([('View', None, _('View'),
> > '<Control>V',
> > None, self.on_treeview_browse_movies_row_activated),
> >                                       ('Edit', gtk.STOCK_EDIT, _('Edit'),
> > None, None,
> > self.on_toolbutton_edit_clicked),
> >                                       ('Delete', gtk.STOCK_DELETE,
> > _('Delete'), None, None,
> > self.on_toolbutton_delete_clicked)])
> >
> > You also have to get the uimanager accelgroup and add it to the toplevel
> > window before inserting the actiongroup in the uimanager. See the
> > uimanager.py example program in the tutorial:
> >
> > http://www.pygtk.org/pygtk2tutorial/sec-UIManager.html#sec-SimpleUIManagerExample
> >
> > John
> It doesn't work the way either. Key combination work, but they won't get
> displayed.
> I tried the same thing with a menubar instead of a popup and their it works.
> 

I thought pop up menus aren't *supposed* to contain accelerator labels.
One is supposed to look in the main menu for them...

At least I recall a rule like that ... was it the HIG? I forgot...

cheers,
  Danny




More information about the pygtk mailing list