From: Kevin A. <ka...@us...> - 2004-08-12 19:14:33
|
Update of /cvsroot/pythoncard/PythonCard/tools/resourceEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15782/resourceEditor Modified Files: resourceEditor.py Log Message: getCommandLineArgs moved to util.py runOptionsDialog moved to templates.dialogs.runOptionsDialog.py dialog.py is now a thin wrapper around wx.lib.dialogs.py all dialog results now use DialogResults class instead of dictionary e.g. result.accepted instead of result['accepted'] see dialogs sample and other samples and tools for examples of change Index: resourceEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/resourceEditor/resourceEditor.py,v retrieving revision 1.203 retrieving revision 1.204 diff -C2 -d -r1.203 -r1.204 *** resourceEditor.py 8 Aug 2004 18:07:45 -0000 1.203 --- resourceEditor.py 12 Aug 2004 19:14:22 -0000 1.204 *************** *** 16,26 **** from PythonCard import about, clipboard, configuration, dialog, graphic, log from PythonCard import menu, model, registry, resource, util from modules.backgroundInfoDialog import BackgroundInfoDialog ! from modules.stackInfoDialog import StackInfoDialog from modules import menuDialog from modules import stringDialog from modules.dialogInfoDialog import DialogInfoDialog - from modules.runOptionsDialog import RunOptionsDialog from modules.propertyEditor import PropertyEditor from modules import resourceOutput --- 16,26 ---- from PythonCard import about, clipboard, configuration, dialog, graphic, log from PythonCard import menu, model, registry, resource, util + from PythonCard.templates.dialogs import runOptionsDialog from modules.backgroundInfoDialog import BackgroundInfoDialog ! from modules import stackInfoDialog from modules import menuDialog from modules import stringDialog from modules.dialogInfoDialog import DialogInfoDialog from modules.propertyEditor import PropertyEditor from modules import resourceOutput *************** *** 53,59 **** self.filename = None self.documentChanged = False ! self.cmdLineArgs = {'debugmenu':0, 'logging':0, 'messagewatcher':0, ! 'namespaceviewer':0, 'propertyeditor':0, ! 'shell':0} self.lastCaptured = None --- 53,59 ---- self.filename = None self.documentChanged = False ! self.cmdLineArgs = {'debugmenu':False, 'logging':False, 'messagewatcher':False, ! 'namespaceviewer':False, 'propertyeditor':False, ! 'shell':False, 'otherargs':''} self.lastCaptured = None *************** *** 682,688 **** msg = "The data in the %s file has changed.\n\nDo you want to save the changes?" % filename result = dialog.messageDialog(self, msg, 'resourceEditor', ! dialog.ICON_EXCLAMATION, ! dialog.BUTTON_YES_NO | dialog.BUTTON_CANCEL) ! return result['returned'] def newFile(self, fullTemplatePath): --- 682,687 ---- msg = "The data in the %s file has changed.\n\nDo you want to save the changes?" % filename result = dialog.messageDialog(self, msg, 'resourceEditor', ! wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL) ! return result.returnedString def newFile(self, fullTemplatePath): *************** *** 713,718 **** # don't set the starting dir, let user navigate result = dialog.saveFileDialog(None, "Save As", "", templateFilename[:-8] + ".py", wildcard) ! if result['accepted']: ! path = result['paths'][0] if path.endswith('.rsrc.py'): --- 712,717 ---- # don't set the starting dir, let user navigate result = dialog.saveFileDialog(None, "Save As", "", templateFilename[:-8] + ".py", wildcard) ! if result.accepted: ! path = result.paths[0] if path.endswith('.rsrc.py'): *************** *** 781,785 **** message = 'The resource file could not be saved.\n' + str( e ) dialog.messageDialog(self, message, 'ResourceEditor Error', ! dialog.ICON_EXCLAMATION,dialog.BUTTON_OK) return False --- 780,784 ---- message = 'The resource file could not be saved.\n' + str( e ) dialog.messageDialog(self, message, 'ResourceEditor Error', ! wx.ICON_EXCLAMATION | wx.OK) return False *************** *** 832,837 **** listX.append(t[0]) result = dialog.singleChoiceDialog(self, "Templates", "Choose a resource template", listX) ! if result['accepted']: ! name = result['selection'] for t in templates: if t[0] == name: --- 831,836 ---- listX.append(t[0]) result = dialog.singleChoiceDialog(self, "Templates", "Choose a resource template", listX) ! if result.accepted: ! name = result.selection for t in templates: if t[0] == name: *************** *** 892,897 **** wildcard = "resource files (*.rsrc.py)|*.rsrc.py" result = dialog.saveFileDialog(None, "Save As", path, filename, wildcard) ! if result['accepted']: ! path = result['paths'][0] # KEA 2002-06-01 # force .rsrc.py extension --- 891,896 ---- wildcard = "resource files (*.rsrc.py)|*.rsrc.py" result = dialog.saveFileDialog(None, "Save As", path, filename, wildcard) ! if result.accepted: ! path = result.paths[0] # KEA 2002-06-01 # force .rsrc.py extension *************** *** 924,930 **** msg = "You will lose any changes you've made to %s.\n\nAre you sure you want to revert to the last saved version?" % filename result = dialog.messageDialog(self, msg, 'resourceEditor', ! dialog.ICON_EXCLAMATION, ! dialog.BUTTON_YES_NO | dialog.BUTTON_CANCEL) ! save = result['returned'] if save == "Cancel" or save == "No": # don't do anything, just go back to editing --- 923,928 ---- msg = "You will lose any changes you've made to %s.\n\nAre you sure you want to revert to the last saved version?" % filename result = dialog.messageDialog(self, msg, 'resourceEditor', ! wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL) ! save = result.returnedString if save == "Cancel" or save == "No": # don't do anything, just go back to editing *************** *** 979,984 **** wildcard = "resource files (*.rsrc.py)|*.rsrc.py" result = dialog.openFileDialog(None, "Import which resource file?", '', '', wildcard) ! if result['accepted']: ! self.openFile(result['paths'][0]) def on_menuFileOpen_select(self, event): --- 977,982 ---- wildcard = "resource files (*.rsrc.py)|*.rsrc.py" result = dialog.openFileDialog(None, "Import which resource file?", '', '', wildcard) ! if result.accepted: ! self.openFile(result.paths[0]) def on_menuFileOpen_select(self, event): *************** *** 1030,1035 **** 'Name for copy:', self.startName + 'Copy') ! if result['accepted']: ! name = result['text'] if name in self.components: dialog.alertDialog(self, name + " already exists", 'Error: Unable to duplicate widget') --- 1028,1033 ---- 'Name for copy:', self.startName + 'Copy') ! if result.accepted: ! name = result.text if name in self.components: dialog.alertDialog(self, name + " already exists", 'Error: Unable to duplicate widget') *************** *** 1086,1092 **** aWidget = self.components[self.startName] msg = "Are you sure you want to delete %s %s?" % (aWidget.__class__.__name__, aWidget.name) ! result = dialog.messageDialog(self, msg, 'Delete Component', ! dialog.ICON_INFORMATION) ! if result['accepted']: self.hideSizingHandles() del self.components[aWidget.name] --- 1084,1089 ---- aWidget = self.components[self.startName] msg = "Are you sure you want to delete %s %s?" % (aWidget.__class__.__name__, aWidget.name) ! result = dialog.messageDialog(self, msg, 'Delete Component', wx.ICON_INFORMATION) ! if result.accepted: self.hideSizingHandles() del self.components[aWidget.name] *************** *** 1252,1274 **** wx.EVT_MOTION(c, self.on_mouseDrag) def on_fileRunOptions_command(self, event): ! dlg = RunOptionsDialog(self, self.cmdLineArgs) ! dlg.showModal() ! if dlg.accepted(): ! self.cmdLineArgs['debugmenu'] = dlg.components.chkDebugMenu.checked ! self.cmdLineArgs['logging'] = dlg.components.chkLogging.checked ! self.cmdLineArgs['messagewatcher'] = dlg.components.chkMessageWatcher.checked ! self.cmdLineArgs['namespaceviewer'] = dlg.components.chkNamespaceViewer.checked ! self.cmdLineArgs['propertyeditor'] = dlg.components.chkPropertyEditor.checked ! self.cmdLineArgs['shell'] = dlg.components.chkShell.checked ! dlg.destroy() def on_editStackInfo_command(self, event): ! dlg = StackInfoDialog(self, self.rsrc) ! dlg.showModal() ! if dlg.accepted(): ! self.rsrc.application.name = dlg.components.fldName.text self.documentChanged = True - dlg.destroy() # need to change the logic so that self.rsrc --- 1249,1274 ---- wx.EVT_MOTION(c, self.on_mouseDrag) + # KEA 2004-08-12 + # for each of the dialogs below, the code should be refactored + # so that the dialog modules have a function wrapper and the + # result contains whatever attributes would be needed + # the function should probably not have side-effects + def on_fileRunOptions_command(self, event): ! result = runOptionsDialog.runOptionsDialog(self, self.cmdLineArgs) ! if result.accepted: ! self.cmdLineArgs['debugmenu'] = result.debugmenu ! self.cmdLineArgs['logging'] = result.logging ! self.cmdLineArgs['messagewatcher'] = result.messagewatcher ! self.cmdLineArgs['namespaceviewer'] = result.namespaceviewer ! self.cmdLineArgs['propertyeditor'] = result.propertyeditor ! self.cmdLineArgs['shell'] = result.shell ! self.cmdLineArgs['otherargs'] = result.otherargs def on_editStackInfo_command(self, event): ! result = stackInfoDialog.stackInfoDialog(self, self.rsrc) ! if result.accepted: ! self.rsrc.application.name = result.text self.documentChanged = True # need to change the logic so that self.rsrc *************** *** 1279,1284 **** background.size = self.GetSizeTuple() dlg = BackgroundInfoDialog(self, background) ! dlg.showModal() ! if dlg.accepted(): background.name = dlg.components.fldName.text background.title = dlg.components.fldTitle.text --- 1279,1284 ---- background.size = self.GetSizeTuple() dlg = BackgroundInfoDialog(self, background) ! result = dlg.showModal() ! if result.accepted: background.name = dlg.components.fldName.text background.title = dlg.components.fldTitle.text *************** *** 1328,1333 **** background.size = self.GetSizeTuple() dlg = DialogInfoDialog(self, background) ! dlg.showModal() ! if dlg.accepted(): background.name = dlg.components.fldName.text background.title = dlg.components.fldTitle.text --- 1328,1333 ---- background.size = self.GetSizeTuple() dlg = DialogInfoDialog(self, background) ! result = dlg.showModal() ! if result.accepted: background.name = dlg.components.fldName.text background.title = dlg.components.fldTitle.text *************** *** 1345,1350 **** menubar = None dlg = menuDialog.MenuDialog(self, menubar) ! dlg.showModal() ! if dlg.accepted(): if len(dlg.menuList) == 0: self.rsrc.application.backgrounds[0].menubar = None --- 1345,1350 ---- menubar = None dlg = menuDialog.MenuDialog(self, menubar) ! result = dlg.showModal() ! if result.accepted: if len(dlg.menuList) == 0: self.rsrc.application.backgrounds[0].menubar = None *************** *** 1366,1371 **** stringList = {} dlg = stringDialog.StringDialog(self, stringList) ! dlg.showModal() ! if dlg.accepted(): if self.editingDialog: self.rsrc.strings = stringDialog.stringResourceFromList(dlg.stringList) --- 1366,1371 ---- stringList = {} dlg = stringDialog.StringDialog(self, stringList) ! result = dlg.showModal() ! if result.accepted: if self.editingDialog: self.rsrc.strings = stringDialog.stringResourceFromList(dlg.stringList) *************** *** 1381,1387 **** 'Enter the preferred grid size (e.g. 5):', str(self.xGridSize)) ! if result['accepted']: try: ! size = int(result['text']) self.xGridSize = size self.yGridSize = size --- 1381,1387 ---- 'Enter the preferred grid size (e.g. 5):', str(self.xGridSize)) ! if result.accepted: try: ! size = int(result.text) self.xGridSize = size self.yGridSize = size *************** *** 1512,1518 **** aWidget = self.components[self.startName] msg = "Are you sure you want to Cut %s %s?" % (aWidget.__class__.__name__, aWidget.name) ! result = dialog.messageDialog(self, msg, 'Cut Component', ! dialog.ICON_INFORMATION) ! if result['accepted']: self.copyWidgetDescriptionToClipboard(self.startName) self.hideSizingHandles() --- 1512,1517 ---- aWidget = self.components[self.startName] msg = "Are you sure you want to Cut %s %s?" % (aWidget.__class__.__name__, aWidget.name) ! result = dialog.messageDialog(self, msg, 'Cut Component', wx.ICON_INFORMATION) ! if result.accepted: self.copyWidgetDescriptionToClipboard(self.startName) self.hideSizingHandles() *************** *** 1543,1548 **** name + ' component already exists\nEnter a new name:', name + 'Copy') ! if result['accepted']: ! name = result['text'] if name in self.components: dialog.alertDialog(self, name + " already exists", 'Error: Unable to duplicate component') --- 1542,1547 ---- name + ' component already exists\nEnter a new name:', name + 'Copy') ! if result.accepted: ! name = result.text if name in self.components: dialog.alertDialog(self, name + " already exists", 'Error: Unable to duplicate component') *************** *** 1603,1609 **** save = self.saveChanges() if save == "Cancel": ! return 0 elif save == "No": ! return 1 else: if self.filename is None: --- 1602,1608 ---- save = self.saveChanges() if save == "Cancel": ! return False elif save == "No": ! return True else: if self.filename is None: *************** *** 1612,1616 **** return self.saveFile() else: ! return 1 def doCleanup(self): --- 1611,1615 ---- return self.saveFile() else: ! return True def doCleanup(self): |