From: Kevin A. <ka...@us...> - 2004-08-12 19:15:01
|
Update of /cvsroot/pythoncard/PythonCard/tools/codeEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15782/codeEditor Modified Files: codeEditor.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: codeEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/codeEditor/codeEditor.py,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** codeEditor.py 8 Aug 2004 18:31:53 -0000 1.121 --- codeEditor.py 12 Aug 2004 19:14:20 -0000 1.122 *************** *** 12,16 **** from PythonCard import about, configuration, dialog, log, menu, model, resource, util ! from modules.runOptionsDialog import RunOptionsDialog from modules import scriptutils import os, sys --- 12,17 ---- from PythonCard import about, configuration, dialog, log, menu, model, resource, util ! from PythonCard.templates.dialogs import runOptionsDialog ! from modules import scriptutils import os, sys *************** *** 95,102 **** self.configPath = os.path.join(configuration.homedir, 'codeeditor') self.loadConfig() ! self.cmdLineArgs = {'debugmenu':0, 'logging':0, 'messagewatcher':0, ! 'namespaceviewer':0, 'propertyeditor':0, ! 'shell':0, 'otherargs':''} ! self.lastFind = {'searchText':'', 'replaceText':'', 'wholeWordsOnly':0, 'caseSensitive':0} self.startTitle = self.title if len(sys.argv) > 1: --- 96,103 ---- self.configPath = os.path.join(configuration.homedir, 'codeeditor') self.loadConfig() ! self.cmdLineArgs = {'debugmenu':False, 'logging':False, 'messagewatcher':False, ! 'namespaceviewer':False, 'propertyeditor':False, ! 'shell':False, 'otherargs':''} ! self.lastFind = {'searchText':'', 'replaceText':'', 'wholeWordsOnly':False, 'caseSensitive':False} self.startTitle = self.title if len(sys.argv) > 1: *************** *** 408,414 **** msg = self.resource.strings.documentChangedPrompt % filename result = dialog.messageDialog(self, msg, self.resource.strings.codeEditor, ! dialog.ICON_EXCLAMATION, ! dialog.BUTTON_YES_NO | dialog.BUTTON_CANCEL) ! return result['returned'] def doExit(self): --- 409,414 ---- msg = self.resource.strings.documentChangedPrompt % filename result = dialog.messageDialog(self, msg, self.resource.strings.codeEditor, ! wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL) ! return result.returnedString def doExit(self): *************** *** 416,422 **** save = self.saveChanges() if save == "Cancel": ! return 0 elif save == "No": ! return 1 else: if self.documentPath is None: --- 416,422 ---- save = self.saveChanges() if save == "Cancel": ! return False elif save == "No": ! return True else: if self.documentPath is None: *************** *** 424,430 **** else: self.saveFile(self.documentPath) ! return 1 else: ! return 1 def on_close(self, event): --- 424,430 ---- else: self.saveFile(self.documentPath) ! return True else: ! return True def on_close(self, event): *************** *** 460,470 **** filename = os.path.basename(self.documentPath) result = dialog.saveFileDialog(None, self.resource.strings.saveAs, dir, filename, wildcard) ! if result['accepted']: ! path = result['paths'][0] self.saveFile(path) self.fileHistory.AddFileToHistory(path) ! return 1 else: ! return 0 def newFile(self): --- 460,470 ---- filename = os.path.basename(self.documentPath) result = dialog.saveFileDialog(None, self.resource.strings.saveAs, dir, filename, wildcard) ! if result.accepted: ! path = result.paths[0] self.saveFile(path) self.fileHistory.AddFileToHistory(path) ! return True else: ! return False def newFile(self): *************** *** 611,616 **** wildcard = self.resource.strings.saveAsWildcard result = dialog.openFileDialog(None, self.resource.strings.openFile, '', '', wildcard) ! if result['accepted']: ! path = result['paths'][0] # an error will probably occur here if the text is too large # to fit in the wxTextCtrl (TextArea) or the file is actually --- 611,616 ---- wildcard = self.resource.strings.saveAsWildcard result = dialog.openFileDialog(None, self.resource.strings.openFile, '', '', wildcard) ! if result.accepted: ! path = result.paths[0] # an error will probably occur here if the text is too large # to fit in the wxTextCtrl (TextArea) or the file is actually *************** *** 734,741 **** lastFind['caseSensitive']) ! if result['accepted']: ! lastFind['searchText'] = result['searchText'] ! lastFind['wholeWordsOnly'] = result['wholeWordsOnly'] ! lastFind['caseSensitive'] = result['caseSensitive'] self.findNext(lastFind['searchText'], --- 734,741 ---- lastFind['caseSensitive']) ! if result.accepted: ! lastFind['searchText'] = result.text ! lastFind['wholeWordsOnly'] = result.wholeword ! lastFind['caseSensitive'] = result.casesensitive self.findNext(lastFind['searchText'], *************** *** 760,766 **** # this version doesn't alert the user if the line number is out-of-range # it just fails quietly ! if result['accepted']: try: ! self.gotoLine(int(result['text'])) except: pass --- 760,766 ---- # this version doesn't alert the user if the line number is out-of-range # it just fails quietly ! if result.accepted: try: ! self.gotoLine(int(result.text)) except: pass *************** *** 898,902 **** % self.wordCount(self.components.document.text), self.resource.strings.about, ! dialog.ICON_INFORMATION, dialog.BUTTON_OK) def on_doHelpAboutPythonCard_command(self, event): --- 898,902 ---- % self.wordCount(self.components.document.text), self.resource.strings.about, ! wx.ICON_INFORMATION | wx.OK) def on_doHelpAboutPythonCard_command(self, event): *************** *** 925,930 **** path = '' result = dialog.directoryDialog(self, 'Choose a directory', path) ! if result['accepted']: ! path = result['path'] os.chdir(path) self.application.shell.run('os.getcwd()') --- 925,930 ---- path = '' result = dialog.directoryDialog(self, 'Choose a directory', path) ! if result.accepted: ! path = result.path os.chdir(path) self.application.shell.run('os.getcwd()') *************** *** 947,952 **** scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.saveFileDialog(None, self.resource.strings.saveAs, scriptletsDir, 'scriptlet.py', wildcard) ! if result['accepted']: ! path = result['paths'][0] f = open(path, 'w') f.write(script) --- 947,952 ---- scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.saveFileDialog(None, self.resource.strings.saveAs, scriptletsDir, 'scriptlet.py', wildcard) ! if result.accepted: ! path = result.paths[0] f = open(path, 'w') f.write(script) *************** *** 972,977 **** scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.openFileDialog(self, self.resource.strings.openFile, scriptletsDir, '', wildcard) ! if result['accepted']: ! filename = result['paths'][0] self.execScriptlet(filename) #os.chdir(curDir) --- 972,977 ---- scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.openFileDialog(self, self.resource.strings.openFile, scriptletsDir, '', wildcard) ! if result.accepted: ! filename = result.paths[0] self.execScriptlet(filename) #os.chdir(curDir) *************** *** 1083,1121 **** scriptutils.CheckFile(self, self.documentPath) self.lastPos = self.components.document.GetCurrentPos() - - # the stuff below was adapted from the resourceEditor - # and can probably be moved to a separate module - # command-line args code - def getCommandLineArgs(self): - args = [] - if self.cmdLineArgs['otherargs'] != '': - args.append(self.cmdLineArgs['otherargs']) - if self.cmdLineArgs['debugmenu']: - args.append('-d') - if self.cmdLineArgs['logging']: - args.append('-l') - if self.cmdLineArgs['messagewatcher']: - args.append('-m') - if self.cmdLineArgs['namespaceviewer']: - args.append('-n') - if self.cmdLineArgs['propertyeditor']: - args.append('-p') - if self.cmdLineArgs['shell']: - args.append('-s') - return args - 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 ! self.cmdLineArgs['otherargs'] = dlg.components.fldOtherArgs.text ! dlg.destroy() --- 1083,1097 ---- scriptutils.CheckFile(self, self.documentPath) self.lastPos = self.components.document.GetCurrentPos() 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 *************** *** 1150,1154 **** # the args should come from a dialog or menu items that are checked/unchecked ! args = self.getCommandLineArgs() # change to the script directory before attempting to run --- 1126,1130 ---- # the args should come from a dialog or menu items that are checked/unchecked ! args = util.getCommandLineArgs(self.cmdLineArgs) # change to the script directory before attempting to run |