@@ -492,6 +492,39 @@ def ResetFont(self):
492492 idleConf .GetOption ('main' ,'EditorWindow' ,'font-size' ),
493493 fontWeight ))
494494
495+ def ResetKeybindings (self ):
496+ #this function is called from configDialog.py
497+ #to update the keybindings if they are changed
498+ self .Bindings .default_keydefs = idleConf .GetCurrentKeySet ()
499+ keydefs = self .Bindings .default_keydefs
500+ for event , keylist in keydefs .items ():
501+ self .text .event_delete (event )
502+ self .apply_bindings ()
503+ #update menu accelerators
504+ menuEventDict = {}
505+ for menu in self .Bindings .menudefs :
506+ menuEventDict [menu [0 ]]= {}
507+ for item in menu [1 ]:
508+ if item :
509+ menuEventDict [menu [0 ]][prepstr (item [0 ])[1 ]]= item [1 ]
510+ for menubarItem in self .menudict .keys ():
511+ menu = self .menudict [menubarItem ]
512+ end = menu .index (END )+ 1
513+ for index in range (0 ,end ):
514+ if menu .type (index )== 'command' :
515+ accel = menu .entrycget (index ,'accelerator' )
516+ if accel :
517+ itemName = menu .entrycget (index ,'label' )
518+ event = ''
519+ if menuEventDict .has_key (menubarItem ):
520+ if menuEventDict [menubarItem ].has_key (itemName ):
521+ event = menuEventDict [menubarItem ][itemName ]
522+ if event :
523+ #print 'accel was:',accel
524+ accel = get_accelerator (keydefs , event )
525+ menu .entryconfig (index ,accelerator = accel )
526+ #print 'accel now:',accel,'\n'
527+
495528 def saved_change_hook (self ):
496529 short = self .short_title ()
497530 long = self .long_title ()
0 commit comments