On Mon, Oct 06, 2003 at 01:16:00PM -0500, Alex Roitman wrote:
> I apologize for asking a silly question here, but I just can't figure
> it out by myself. I am creating a submenu of a main menu of a gnome
> program. I would like to add accelerators to the menu items of my menu.
I've had this problem before myself.
> gomenu = gtk.Menu()
> back = gtk.ImageMenuItem(gtk.STOCK_GO_BACK)
> back.connect("activate",self.back_clicked)
> back.show()
> gomenu.append(self.back)
>
> The above snippet works. But when I attempt to add an accelerator using
> back.add_accelerator()
> is when I get in trouble. The add_accelerator() method of gtk.Widget
> wants accel_group as its second argument. What am I supposed to give
> it?
>
> I tried None (does not work) and an empty gtk.AccelGroup() (works but
> produces complains about not being able to connect to the accel group).
Hmmm. You should save a reference to your AccelGroup, but I'm curious as
to what happens when you set pass in group to add_accelerator().
Have you looked at the GTK+ documentation for AccelGroups? It should be
simple to translate examples to PyGTK from that.
> I also tried obtaining the get_accel_group() of the present menu, which
> returns None. I probably should add here that the whole menu hierarchy
> was created in glade and parsed using libglade. I want to just create
> this little submenu from the python code.
I talked to James over IRC about this once; there's an issue that (in a
similar situation as signals connected via libglade) there isn't an easy
way to reach accelerator groups that are created during the libglade
parse for most/some of the GTK+ widgets.
*However*, when I asked him, I was referring to keyboard accelerators in
widgets *other* than GtkMenu, and since GtkMenu *does* provide an API to
get to its accel_group, I'm as to why get_accel_group() is returning
None. It may very well be a bug.
Take care,
--
Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/