From: Kevin A. <ka...@us...> - 2004-08-27 02:03:34
|
Update of /cvsroot/pythoncard/PythonCard/tools/codeEditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17381/tools/codeEditor Modified Files: restEditor.py restEditor.rsrc.py Log Message: simplistic save for HTML in preview window Index: restEditor.rsrc.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/codeEditor/restEditor.rsrc.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** restEditor.rsrc.py 24 Aug 2004 14:19:31 -0000 1.5 --- restEditor.rsrc.py 27 Aug 2004 02:03:25 -0000 1.6 *************** *** 38,41 **** --- 38,46 ---- }, {'type':'MenuItem', + 'name':'menuFileSaveHtml', + 'label':'Save HTML As...', + 'command':'saveHtml', + }, + {'type':'MenuItem', 'name':'fileSep1', 'label':'-', Index: restEditor.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/tools/codeEditor/restEditor.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** restEditor.py 25 Aug 2004 18:08:18 -0000 1.6 --- restEditor.py 27 Aug 2004 02:03:25 -0000 1.7 *************** *** 7,11 **** import os ! from PythonCard import model from codeEditor import CodeEditor from wx import stc --- 7,11 ---- import os ! from PythonCard import dialog, model from codeEditor import CodeEditor from wx import stc *************** *** 25,28 **** --- 25,29 ---- #self.previewWindow.position = (425, -1) self.previewWindow.visible = True + self.html = '' # reST *************** *** 36,40 **** html = txt else: ! html = '<html><head></head><body>' + txt + '</body></html>' else: # KEA 2004-08-15 --- 37,41 ---- html = txt else: ! html = '<html>\n<head>\n</head>\n<body>\n' + txt + '\n</body>\n</html>\n' else: # KEA 2004-08-15 *************** *** 44,48 **** rest = restify(txt) if rest: ! html = '<html><head></head><body>' + rest + '</body></html>' else: html = self.previewWindow.components.html.text --- 45,49 ---- rest = restify(txt) if rest: ! html = '<html>\n<head>\n</head>\n<body>\n' + rest + '\n</body>\n</html>\n' else: html = self.previewWindow.components.html.text *************** *** 63,66 **** --- 64,91 ---- event.skip() + def saveHtmlFile(self, path): + try: + f = open(path, 'wb') + try: + f.write(self.html) + finally: + f.close() + except: + pass + + def on_saveHtml_command(self, event): + wildcard = "HTML files (*.html)|*.html|All files (*.*)|*.*" + #wildcard = self.resource.strings.saveAsWildcard + if self.documentPath is None: + dir = '' + filename = '*.html' + else: + dir = os.path.dirname(self.documentPath) + filename = os.path.splitext(os.path.basename(self.documentPath))[0] + '.html' + result = dialog.saveFileDialog(None, self.resource.strings.saveAs, dir, filename, wildcard) + if result.accepted: + path = result.paths[0] + self.saveHtmlFile(path) + def on_menuFormatRenderOnReturn_select(self, event): self.renderOnReturn = self.menuBar.getChecked('menuFormatRenderOnReturn') |