Hi everybody,
I'm trying to add a global hotkey to a menuitem which has a sub menu.
Here is what I did:
import pygtk, gtk
import keybinder
dlg = gtk.Dialog('menu test')
dlg.set_size_request(200, 40)
menubar = gtk.MenuBar()
menubar.show()
menuitem = gtk.MenuItem('foo')
menuitem.show()
menubar.append(menuitem)
mitem = gtk.MenuItem('bar')
mitem.show()
menu = gtk.Menu()
menu.add(mitem)
menu.show()
menuitem.set_submenu(menu)
def show_menu_cb():
menubar.select_item(menuitem)
keybinder.bind('<Super>i', show_menu_cb)
dlg.vbox.pack_start(menubar)
dlg.show()
dlg.run()
When I press the hotkey, the sub menu shows up.
I can then select the items in the sub menu or press Esc to cancel the
selection.
But after that other applications never get focus again.
I have to click the menu item twice to get everything back to normal.
I looked at gtkmenushell.c and found nothing helpful.
Any help would be greatly appreciated.
--
Shaung
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/