|
From: Arlo B. <abe...@us...> - 2004-10-24 19:43:56
|
Update of /cvsroot/pythoncard/PythonCard/tools/experimentalResourceEditor/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32733/modules Added Files: actionBinderDialog.py actionBinderDialog.rsrc.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 --- NEW FILE: actionBinderDialog.py --- """ __version__ = "$Revision: 1.1 $" __date__ = "$Date: 2004/10/24 19:43:43 $" """ from PythonCard import model class ActionBinderDialog(model.CustomDialog): def __init__(self, parent): model.CustomDialog.__init__(self, parent) self.resource_editor = parent for inst in self.resource_editor.components.keys(): self.components.sourceComponent.append(inst) self.components.destinationComponent.append(inst) # if some special setup is necessary, do it here # example from samples/dialogs/minimalDialog.py # self.components.field1.text = txt def on_sourceComponent_select(self, wx_event): the_widget = self.resource_editor.components[wx_event.stringSelection] self.components.sourceEvent.clear() for evt in the_widget._spec.getEventNames(): self.components.sourceEvent.append(evt) self.components.sourceComponent.selected = wx_event.stringSelection def on_btnApply_mouseClick(self, wx_event): sourceComponent = self.components.sourceComponent.stringSelection sourceEvent = self.components.sourceEvent.stringSelection destinationComponent = self.components.destinationComponent.stringSelection destinationFunction = self.components.destinationFunction.text if max(len(sourceComponent), len(sourceEvent), len(destinationComponent), len(destinationFunction)) == 0: return the_widget = self.resource_editor.components[sourceComponent] actionBindings = the_widget.actionBindings actionBindings[sourceEvent] = (destinationComponent, destinationFunction) self.resource_editor.documentChanged = True def runDialog(parent): dlg = ActionBinderDialog(parent) result = dlg.showModal() # stick your results into the result dictionary here # example from samples/dialogs/minimalDialog.py # result.text = dlg.components.field1.text dlg.destroy() return result --- NEW FILE: actionBinderDialog.rsrc.py --- {'type':'CustomDialog', 'name':'Template', 'title':'Dialog Template', 'position':(41, 87), 'size':(711, 538), 'components': [ {'type':'Button', 'name':'btnApply', 'position':(596, 407), 'label':'&Apply', }, {'type':'TextField', 'name':'destinationFunction', 'position':(434, 10), 'size':(250, -1), }, {'type':'List', 'name':'destinationComponent', 'position':(300, 10), 'size':(-1, 421), 'items':[], }, {'type':'List', 'name':'sourceEvent', 'position':(155, 10), 'size':(-1, 421), 'items':[], }, {'type':'List', 'name':'sourceComponent', 'position':(10, 10), 'size':(-1, 421), 'items':[], }, ] # end components } # end CustomDialog |