Hi, Am Montag, den 30.05.2005, 11:06 +0200 schrieb Calle Erlandsson: > When I asked on the irc-channel, I got no good answer, that's why I'm > asking here; > I want to connect the keycombination Ctrl+s with a function (a save > function ;). I've got a menuitem wich is connected to the function. > I've not used an itemfactory or an uimanager to create the menus. > What do I have to do, to connect the Ctrl+S event with the function?
Depends on if you want the user to be able to change the accelerator by
hovering menu item + pressing keys.
If not (not recommended):
ag = gtk.AccelGroup()
window.add_accel_group(ag)
menuitem.add_accelerator("activated", ag, gtk.gdk.keyval_from_name("S"),
gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
----
If so (recommended):
# create accelgroup, add to window
ag = gtk.AccelGroup()
window.add_accel_group(ag)
menu = gtk.Menu()
menu.set_accel_group(ag)
menuitem = gtk.MenuItem("boo")
# set unique path to identify the menuitem
menuitem.set_accel_path("<SomeName>/SomeName/SomeName/MenuItemName")
menu.append(menuitem)
and at the end of the prog 'gtk.accel_map_save("moo")' and at the
beginning of the prog (after setting up the menus), call
'gtk.accel_map_load("moo")', and if the load fails,
gtk.accel_map_change_entry("<SomeName>/SomeName/SomeName/MenuItemName",
gtk.gdk.keyval_from_name("S"), gtk.gdk.CONTROL_MASK, True)
>
> --
>
> /Calle
cheers,
Danny
--
www.keyserver.net key id A334AEA6
signature.asc
Description: This is a digitally signed message part
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
