From: Kevin A. <ka...@us...> - 2004-05-06 17:33:21
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14515 Modified Files: menu.py model.py Log Message: fixed enableCommand and disableCommand Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** model.py 5 May 2004 20:27:07 -0000 1.165 --- model.py 6 May 2004 17:33:13 -0000 1.166 *************** *** 870,883 **** ! def enableCommand(self, aString): """ Fined every component with a 'command' attribute that matches aString, and enable the component. """ ! self.menuBar.enableCommand(aString) for component in self.components.itervalues(): ! if component._getCommand() is aString: ! component.setEnabled(1) def disableCommand(self, aString): --- 870,883 ---- ! def enableCommand(self, aString, aBoolean=True): """ Fined every component with a 'command' attribute that matches aString, and enable the component. """ ! self.menuBar.enableCommand(aString, aBoolean) for component in self.components.itervalues(): ! if component.command == aString: ! component.enabled = aBoolean def disableCommand(self, aString): *************** *** 886,895 **** that matches aString, and disable the component. """ ! self.menuBar.disableCommand(aString) ! ! for component in self.components.itervalues(): ! if component._getCommand() is aString: ! component.setEnabled(0) ! def _initLayout(self, aResourceList): --- 886,890 ---- that matches aString, and disable the component. """ ! self.enableCommand(aString, False) def _initLayout(self, aResourceList): *************** *** 1211,1235 **** ! def enableCommand( self, aString ) : """ Fined every component with a 'command' attribute that matches aString, and enable the component. """ ! self.menuBar.enableCommand( aString ) ! ! for component in self.components.itervalues() : ! if component._getCommand() is aString : ! component.setEnabled( 1 ) ! def disableCommand( self, aString ) : """ Fined every component with a 'command' attribute that matches aString, and disable the component. """ ! self.menuBar.disableCommand( aString ) ! ! for component in self.components.itervalues() : ! if component._getCommand() is aString : ! component.setEnabled( 0 ) --- 1206,1224 ---- ! def enableCommand(self, aString, aBoolean=True): """ Fined every component with a 'command' attribute that matches aString, and enable the component. """ ! for component in self.components.itervalues(): ! if component.command == aString: ! component.enabled = aBoolean ! def disableCommand(self, aString): """ Fined every component with a 'command' attribute that matches aString, and disable the component. """ ! self.enableCommand(aString, False) Index: menu.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/menu.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** menu.py 6 May 2004 01:30:22 -0000 1.35 --- menu.py 6 May 2004 17:33:13 -0000 1.36 *************** *** 84,87 **** --- 84,92 ---- self._bindEvents((MenuSelectEvent,), aScriptable, id) + # KEA 2004-05-06 + # since the only use of id2itemMap + # is enableCommand and disableCommand + # it might make more sense to just store + # a mapping of command names to ids aParent.parent.id2itemMap[id] = self *************** *** 194,197 **** --- 199,208 ---- background = aWxEvent.GetEventObject().parent.parent else: + # KEA 2004-05-05 + # it looks like Windows is actually the busted platform + # this time + # if we end up caching the handlers as bound methods + # then I guess this kind of problem would go away because + # we won't have to supply the first arg "self" background = aWxEvent.GetEventObject() ## background = wx.GetTopLevelParent(self) *************** *** 420,437 **** return self.menus ! # KEA 2003-08-02 ! # why don't these do anything?! ! # go ahead and add the code so they are functional ! def enableCommand( self, aString ) : ! for item in self.id2itemMap.itervalues() : ! if item.getCommand() is aString : ! print 'enabling menu item', item.getName() ! pass ! def disableCommand( self, aString ) : ! for item in self.id2itemMap.itervalues() : ! if item.getCommand() is aString : ! print 'disabling menu item', item.getName() ! pass --- 431,441 ---- return self.menus ! def enableCommand(self, aString, aBoolean=True): ! for item in self.id2itemMap.itervalues(): ! if item.command == aString : ! self.Enable(item.GetId(), aBoolean) ! def disableCommand(self, aString): ! self.enableCommand(aString, False) |