|
Re: how do I do reassignable keybindings for menu items?: msg#00081gnome.gtk+.python
Thomas Mills Hinkle wrote: Can anyone point me to a faq/post that explains/hints at how to doYou have to set the "gtk-can-change-accels" property of the Settings object to True after you create a Menu: http://www.pygtk.org/pygtk2reference/class-gtksettings.html You have to specify the accelerators using accel paths gtk.accel_map_change_entry() and associate accel paths with your menu items using gtk.MenuItem.set_accel_path() or gtk.Menu.set_accel_path(): http://www.pygtk.org/pygtk2reference/class-gtkaccelgroup.html#function-gtk--accel-map-change-entry http://www.pygtk.org/pygtk2reference/class-gtkmenuitem.html#method-gtkmenuitem--set-accel-path http://www.pygtk.org/pygtk2reference/class-gtkmenu.html#method-gtkmenu--set-accel-path Also, I'd like to find the right place to report a UI bug with thisThe accel_map entries can be prevented from changing by locking them individually using gtk.accel_map_lock_path(): http://www.pygtk.org/pygtk2reference/class-gtkaccelgroup.html#function-gtk--accel-map-lock-path I've attached a simple example illustrating that the accelerator on the "Test" menu item can be changed to say "Control-G" but not to "Control-E" which is used by the "Other" menu item which is locked. Given your description is sounds like your bug should be filed against epiphany. John import gtk settings = gtk.settings_get_default() w = gtk.Window() mb = gtk.MenuBar() w.add(mb) ag = gtk.AccelGroup() mi = gtk.MenuItem('Top') mb.append(mi) m = gtk.Menu() settings.set_property('gtk-can-change-accels', True) mi.set_submenu(m) mi1 = gtk.MenuItem('Test') m.append(mi1) mi2 = gtk.MenuItem('Other') m.append(mi2) m.set_accel_group(ag) w.add_accel_group(ag) m.set_accel_path('<test>/Top') gtk.accel_map_change_entry('<test>/Top/Test', ord('d'), gtk.gdk.CONTROL_MASK, True) gtk.accel_map_change_entry('<test>/Top/Other', ord('e'), gtk.gdk.CONTROL_MASK, True) gtk.accel_map_lock_path('<test>/Top/Other') def cb(*args): print args mi1.connect('activate', cb) mi2.connect('activate', cb) w.show_all() gtk.main() _______________________________________________ pygtk mailing list pygtk@xxxxxxxxxx http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Building Public Information Terminal: 00081, Danny Milosavljevic |
|---|---|
| Next by Date: | Re: stock item: 00081, Marcus Habermehl |
| Previous by Thread: | how do I do reassignable keybindings for menu items?i: 00081, Thomas Mills Hinkle |
| Next by Thread: | libnautilus-burn-python on gnome-python-extras?: 00081, Tiago Cogumbreiro |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |