From: Kevin A. <ka...@us...> - 2004-08-12 19:14:33
|
Update of /cvsroot/pythoncard/PythonCard/tools/textEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15782/textEditor Modified Files: textEditor.pyw 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: textEditor.pyw =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/textEditor/textEditor.pyw,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** textEditor.pyw 10 May 2004 00:45:25 -0000 1.73 --- textEditor.pyw 12 Aug 2004 19:14:23 -0000 1.74 *************** *** 15,18 **** --- 15,19 ---- from PythonCard import configuration, dialog, log, model, resource, util + from PythonCard.templates.dialogs import findDialog import os, sys import wx *************** *** 29,71 **** return html - class FindDialog(model.CustomDialog): - def __init__(self, aBg, searchText='', wholeWordsOnly=0, caseSensitive=0) : - # load the resource - path = os.path.join(aBg.application.applicationDirectory, \ - model.internationalResourceName('find')) - aDialogRsrc = resource.ResourceFile(path).getResource() - - model.CustomDialog.__init__(self, aBg, aDialogRsrc) - - self.parent = aBg - - # if some special setup is necessary, do it here - self.components.fldFind.text = searchText - self.components.chkMatchWholeWordOnly.checked = wholeWordsOnly - self.components.chkMatchCase.checked = caseSensitive - self.components.fldFind.setSelection(0, len(self.components.fldFind.text)) - self.components.fldFind.setFocus() - - # these shouldn't be necessary - # but I haven't taken the time to figure out what is messed up in - # the event dispatch that keeps event.skip from being called automatically - # there might be a problem specific to wxDialog - def on_btnFindNext_mouseClick(self, event): - event.skip() - - def on_btnCancel_mouseClick(self, event): - event.skip() - - - def findDialog(parent, searchText='', wholeWordsOnly=0, caseSensitive=0): - dlg = FindDialog(parent, searchText, wholeWordsOnly, caseSensitive) - dlg.showModal() - result = {'accepted':dlg.accepted()} - result['searchText'] = dlg.components.fldFind.text - result['wholeWordsOnly'] = dlg.components.chkMatchWholeWordOnly.checked - result['caseSensitive'] = dlg.components.chkMatchCase.checked - dlg.destroy() - return result - class TextEditor(model.Background): --- 30,33 ---- *************** *** 194,200 **** msg = "The text in the %s file has changed.\n\nDo you want to save the changes?" % filename result = dialog.messageDialog(self, msg, 'textEditor', ! dialog.ICON_EXCLAMATION, ! dialog.BUTTON_YES_NO | dialog.BUTTON_CANCEL) ! return result['returned'] def doExit(self): --- 156,161 ---- msg = "The text in the %s file has changed.\n\nDo you want to save the changes?" % filename result = dialog.messageDialog(self, msg, 'textEditor', ! wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL) ! return result.returnedString def doExit(self): *************** *** 202,208 **** save = self.saveChanges() if save == "Cancel": ! return 0 elif save == "No": ! return 1 else: if self.documentPath is None: --- 163,169 ---- save = self.saveChanges() if save == "Cancel": ! return False elif save == "No": ! return True else: if self.documentPath is None: *************** *** 210,216 **** else: self.saveFile(self.documentPath) ! return 1 else: ! return 1 def on_close(self, event): --- 171,177 ---- else: self.saveFile(self.documentPath) ! return True else: ! return True def on_close(self, event): *************** *** 226,231 **** def on_doSetFont_command(self, event): result = dialog.fontDialog(self, self.components.fldDocument.font) ! if result['accepted']: ! self.config['defaultFont'] = result['font'] self.setDocumentFont() --- 187,192 ---- def on_doSetFont_command(self, event): result = dialog.fontDialog(self, self.components.fldDocument.font) ! if result.accepted: ! self.config['defaultFont'] = result.font self.setDocumentFont() *************** *** 246,259 **** filename = os.path.basename(self.documentPath) result = dialog.saveFileDialog(None, "Save As", dir, filename, wildcard) ! if result['accepted']: ! path = result['paths'][0] self.saveFile(path) self.fileHistory.AddFileToHistory(path) ! return 1 else: ! return 0 def on_fldDocument_textUpdate(self, event): ! self.documentChanged = 1 def newFile(self): --- 207,220 ---- filename = os.path.basename(self.documentPath) result = dialog.saveFileDialog(None, "Save As", dir, filename, wildcard) ! if result.accepted: ! path = result.paths[0] self.saveFile(path) self.fileHistory.AddFileToHistory(path) ! return True else: ! return False def on_fldDocument_textUpdate(self, event): ! self.documentChanged = True def newFile(self): *************** *** 331,336 **** wildcard = "Text files (*.txt)|*.txt;*.TXT|All files (*.*)|*.*" result = dialog.openFileDialog(wildcard=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 --- 292,297 ---- wildcard = "Text files (*.txt)|*.txt;*.TXT|All files (*.*)|*.*" result = dialog.openFileDialog(wildcard=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 *************** *** 419,424 **** # two versions of Find, the first one is using the FindDialog # defined in dialog.py, the second one is using a FindDialog class ! # defined in this source file based on the GenericDialog class ! # in dialog.py # the second one is what you should base your own dialogs on """ --- 380,384 ---- # two versions of Find, the first one is using the FindDialog # defined in dialog.py, the second one is using a FindDialog class ! # defined in templates.dialogs.findDialog # the second one is what you should base your own dialogs on """ *************** *** 432,439 **** lastFind['caseSensitive']) ! if result['accepted']: ! lastFind['searchText'] = result['searchText'] ! lastFind['wholeWordsOnly'] = result['wholeWordsOnly'] ! lastFind['caseSensitive'] = result['caseSensitive'] self.findNext(lastFind['searchText'], --- 392,399 ---- lastFind['caseSensitive']) ! if result.accepted: ! lastFind['searchText'] = result.searchText ! lastFind['wholeWordsOnly'] = result.wholeWordsOnly ! lastFind['caseSensitive'] = result.caseSensitive self.findNext(lastFind['searchText'], *************** *** 487,493 **** # 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 --- 447,453 ---- # 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 *************** *** 514,518 **** % self.wordCount(self.components.fldDocument.text), 'About textEditor...', ! dialog.ICON_INFORMATION, dialog.BUTTON_OK) --- 474,478 ---- % self.wordCount(self.components.fldDocument.text), 'About textEditor...', ! wx.ICON_INFORMATION | wx.OK) *************** *** 537,542 **** scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.saveFileDialog(None, "Save As", scriptletsDir, 'scriptlet.py', wildcard) ! if result['accepted']: ! path = result['paths'][0] f = open(path, 'w') f.write(script) --- 497,502 ---- scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.saveFileDialog(None, "Save As", scriptletsDir, 'scriptlet.py', wildcard) ! if result.accepted: ! path = result.paths[0] f = open(path, 'w') f.write(script) *************** *** 554,559 **** scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.openFileDialog(self, 'Open', scriptletsDir, '', wildcard) ! if result['accepted']: ! filename = result['paths'][0] try: command = 'execfile(%r)' % filename --- 514,519 ---- scriptletsDir = os.path.join(self.application.applicationDirectory, 'scriptlets') result = dialog.openFileDialog(self, 'Open', scriptletsDir, '', wildcard) ! if result.accepted: ! filename = result.paths[0] try: command = 'execfile(%r)' % filename |