From: Arlo B. <abe...@us...> - 2004-10-24 19:43:40
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32709 Modified Files: widget.py Log Message: Added a dialog to the resource editor that binds actions. Widget treats these bindings as extensions to the set provided by specifically-named functions on the background (the background's functions override the bindings set in the dialog). Abel, Lion Index: widget.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/widget.py,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** widget.py 14 Sep 2004 17:28:45 -0000 1.133 --- widget.py 24 Oct 2004 19:43:31 -0000 1.134 *************** *** 34,37 **** --- 34,38 ---- 'position' : { 'presence' : 'optional', 'default' : [ -1, -1 ] }, 'size' : { 'presence' : 'optional', 'default' : [ -1, -1 ] }, + 'actionBindings' : {'presence':'optional', 'default':None}, 'userdata' : {'presence':'optional', 'default':''} } *************** *** 64,67 **** --- 65,72 ---- self._name = aResource.name self._setUserdata(self._resource.userdata) + if self._resource.actionBindings is None: + self._setActionBindings(dict()) + else: + self._setActionBindings(dict(self._resource.actionBindings.__dict__)) self._setCommand(self._resource.command) # KEA 2004-04-23 *************** *** 144,147 **** --- 149,158 ---- self.SetFont( aWxFont ) + def _getActionBindings(self): + return self._actionBindings + + def _setActionBindings(self, actionDict): + self._actionBindings = actionDict + def _getUserdata(self): return self._userdata *************** *** 228,231 **** --- 239,243 ---- size = property(_getSize, _setSize) toolTip = property(_getToolTip, _setToolTip) + actionBindings = property(_getActionBindings, _setActionBindings) userdata = property(_getUserdata, _setUserdata) visible = property(_getVisible, _setVisible) *************** *** 276,279 **** --- 288,294 ---- print "\nBINDING...", self.name + actionBindings = {} + if self.actionBindings is not None: + actionBindings = self.actionBindings for eventClass in eventList: #for eventClass in ButtonEvents: *************** *** 294,297 **** --- 309,321 ---- if not handler: handler = background.findHandler('on_' + eventClass.name) + if not handler: + handlerData = actionBindings.get(eventClass.name) + if handlerData is not None: + handlerObjectName, handlerFunction = handlerData + handlerObject = background.components.get(handlerObjectName) + if handlerObject is not None: + handler = getattr(handlerObject, handlerFunction, None) + if not handler: + handler = background.findHandler('on_' + handlerObjectName + '_' + handlerFunction) if handler or bindUnusedEvents: # only bind events that have an event handler |