Exemplo n.º 1
0
 def on_save_command(self, event):
     '''
         Save project in json format
     '''
     if not self.filename:
         result = dialog.saveFileDialog(self, 'Save', '', '', '*.json')
         if result.accepted:
             self.filename = result.paths[0]
             self.components.usedFileName.text = self.filename
     if self.filename:
         self.task_list = []
         for i in self.components.tasklist.items:
             d = {'name':i[2], 'period':float(i[1]), 'body':i[3]}
             self.task_list.append(d)
         d = {}
         me = self.components
         d['initJALCode'] = self.initJALCode
         d['task_list'] = self.task_list
         d['picmodel'] = me.picmodel.selection
         d['cpufreq'] = me.cpufreq.selection
         d['prescaler'] = me.prescaler.selection
         d['inittmr0'] = int(me.inittmr0.text)
         f = open(self.filename, "wt")
         f.write(json.dumps(d, sort_keys=True, indent=4, separators=(',', ': ')))
         f.close()
     self.changedFlag = False
Exemplo n.º 2
0
 def on_menuScriptletSaveShellSelection_select(self, event):
     if self.application.shell is not None:
         txt = self.application.shell.GetSelectedText()
         lines = []
         for line in txt.splitlines():
             lines.append(self.application.shell.lstripPrompt(line))
         # this is the quick way to convert a list back into a string
         # appending to strings can be slow because it creates a new string
         # each time, so a list is used instead while building up the script
         script = '\n'.join(lines)
         try:
             #wildcard = "Python files (*.py)|*.py|All Files (*.*)|*.*"
             wildcard = self.resource.strings.scriptletWildcard
             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)
                 f.close()
         except:
             pass
Exemplo n.º 3
0
    def on_menuFileSaveAs_select(self, event):
        if self.filename is None:
            path = ''
            filename = ''
        else:
            path, filename = os.path.split(self.filename)
            
        comp = self.components
        style = comp.radDrawingStyle.stringSelection[0]
        filename = 'spiro' + str(comp.sldFixedCircleRadius.value) + '_' + \
            str(comp.sldMovingCircleRadius.value) + '_' + \
            str(comp.sldMovingCircleOffset.value) + '_' + \
            str(comp.btnColor.backgroundColor) + '_' + \
            str(comp.chkDarkCanvas.checked) + '_' + \
            style + '_' + \
            str(comp.sldRevolutionsInRadians.value) + \
            '.png'

        wildcard = "All files (*.*)|*.*"
        result = dialog.saveFileDialog(None, "Save As", path, filename, wildcard)
        if result.accepted:
            path = result.paths[0]
            fileType = graphic.bitmapType(path)
            try:
                bmp = self.components.bufOff.getBitmap()
                bmp.SaveFile(path, fileType)
                return True
            except IOError, msg:
                return False
Exemplo n.º 4
0
 def on_menuFileSaveAs_select(self, event):
     self.bmp = clipboard.getClipboard()
     if not isinstance(self.bmp, wx.Bitmap):
         return
     if self.filename is None:
         path = ''
         filename = ''
     else:
         path, filename = os.path.split(self.filename)
     # wxPython can't save GIF due to the license issues
     # but we can save most other formats, so this list can be expanded
     wildcard = "PNG files (*.png)|*.PNG;*.png" + \
                "|JPG files (*.jpg;*.jpeg)|*.jpeg;*.JPG;*.JPEG;*.jpg" + \
                "|BMP files (*.bmp)|*.BMP;*.bmp" + \
                "|All Files (*.*)|*.*"
     result = dialog.saveFileDialog(None, "Save As", path, filename, wildcard)
     if result.accepted:
         path = result.paths[0]
         fileType = graphic.bitmapType(path)
         #print fileType, path
         self.filename = path
         self.bmp.SaveFile(path, fileType)
         return True
     else:
         return False
Exemplo n.º 5
0
 def on_cmdSave_mouseClick(self, event):
     wildcard = "Map files (*.map)|*.MAP;*.map|All files (*.*)|*.*"
     dir = os.path.dirname('.')
     filename = os.path.basename('NewMap')
     result = dialog.saveFileDialog(None, "Save Map", dir, filename, wildcard)
     if result.accepted:
         path = result.paths[0]
         self.saveMap(path)
         self.changedFile = False
         return True
     else:
         return False
Exemplo n.º 6
0
 def save_file_dlg(self, title, wildcard):
     file_name = None
     if wxver >= 2.9:  # use wx dialogs directly as python card save dialogs are broken after wx 2.9
         dlg = wx.FileDialog(self, title, '', '', wildcard, wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) # @UndefinedVariable
         if dlg.ShowModal() != wx.ID_CANCEL: # @UndefinedVariable
             file_name = dlg.GetPath()
     else:
         result = dialog.saveFileDialog(self, 'Choose a file name', '', '', wildcard)
         if result.accepted == True:
             file_name = result.paths[0]
     self.reset_status_bar()
     return file_name
Exemplo n.º 7
0
 def on_cmdExportXML_mouseClick(self, event):
     wildcard = "XML files (*.xml)|*.XML;*.xml|All files (*.*)|*.*"
     dir = os.path.dirname('.')
     filename = os.path.basename('NewMap')
     result = dialog.saveFileDialog(None, "Export XML Map", dir, filename, wildcard)
     if result.accepted:
         path = result.paths[0]
         self.exportXMLMap(path)
         self.changedFile = False
         return True
     else:
         return False    
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 def on_menuFileSaveAs_select(self, event):
     wildcard = "Grep files (*.grep)|*.grep|All files (*.*)|*.*"
     if self.documentPath is None:
         dir = ''
         filename = '*.grep'
     else:
         dir = os.path.dirname(self.documentPath)
         filename = os.path.basename(self.documentPath)
     result = dialog.saveFileDialog(None, "Save As", dir, filename, wildcard)
     if result.accepted:
         path = result.paths[0]
         self.saveGrepFile(path)
         return True
     else:
         return False
Exemplo n.º 10
0
    def saveAs(self):
        wildcard = "*.mtg"
        result = dialog.saveFileDialog(wildcard=wildcard)

        if result.accepted:
            path = result.paths[0]
            if not match(r'.*\.mtg$', path):
                path = path + '.mtg'
                # note (todo?): since this isn't integrated into
                # saveFileDialog, weird stuff can happen like if you
                # type /tmp/test, and there's already a /tmp/test, it'll
                # ask you if you want to overwrite it, but then if you confirm
                # it'll save to /tmp/test.mtg
            self.currentSavePath = path
            pickle.dump(self.p,open(path,'w'))
Exemplo n.º 11
0
 def on_saveas_command(self, event):
     '''
         Save As
     '''
     try:
         wildcard = "JSON files (*.json)|*.json|All Files (*.*)|*.*"
         result = dialog.saveFileDialog(wildcard=wildcard)
         if result.accepted:
             filename = result.paths[0]
             self._saveData(filename)
             self.loadedFilename = filename
             dialog.messageDialog(self, 'Saved', 'Saved',
                                  wx.ICON_INFORMATION | wx.OK)
             self.title = self.loadedFilename
     except Exception as ex:
         err = traceback.format_exc()
         dialog.messageDialog(self, err, 'Error', wx.ICON_ERROR | wx.OK)
Exemplo n.º 12
0
 def on_menuFileSaveAs_select(self, event):
     if self.filename is None:
         path = ''
         filename = ''
     else:
         path, filename = os.path.split(self.filename)
     result = dialog.saveFileDialog(None, "Save As", path, filename)
     if result.accepted:
         path = result.paths[0]
         fileType = graphic.bitmapType(path)
         print fileType, path
         try:
             bmp = self.components.bufOff.getBitmap()
             bmp.SaveFile(path, fileType)
             return 1
         except IOError, msg:
             return 0
Exemplo n.º 13
0
 def on_menuFileSaveAs_select(self, event):
     if self.filename is None:
         path = ''
         filename = ''
     else:
         path, filename = os.path.split(self.filename)
     result = dialog.saveFileDialog(None, "Save As", path, filename)
     if result.accepted:
         path = result.paths[0]
         fileType = graphic.bitmapType(path)
         print fileType, path
         try:
             #bmp = self.components.bufOff.getBitmap()
             bmp = self.win3.components.bufOff.getBitmap()
             bmp.SaveFile(path, fileType)
             return 1
         except Exception, msg: # Should check for a particular exception
             return 0
Exemplo n.º 14
0
 def on_menuFileSaveAs_select(self, event):
     #wildcard = "Python scripts (*.py;*.pyw)|*.py;*.pyw|Text files (*.txt)|*.txt|All files (*.*)|*.*"
     wildcard = self.resource.strings.saveAsWildcard
     if self.documentPath is None:
         dir = ''
         filename = '*.py'
     else:
         dir = os.path.dirname(self.documentPath)
         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
Exemplo n.º 15
0
 def on_menuFileSaveAs_select(self, event):
     if self.filename is None:
         path = ''
         filename = ''
     else:
         path, filename = os.path.split(self.filename)
     result = dialog.saveFileDialog(None, "Save As", path, filename)
     if result.accepted:
         path = result.paths[0]
         fileType = graphic.bitmapType(path)
         print fileType, path
         try:
             bmp = self.components.bufOff.getBitmap()
             bmp.SaveFile(path, fileType)
             return 1
         except:
             return 0
     else:
         return 0
Exemplo n.º 16
0
    def on_menuSaveMeetingMinutesAsFile_select(self, event):
        event.skip()
        wildcard = "*.txt"
        result = dialog.saveFileDialog(wildcard=wildcard)

        if result.accepted:
            path = result.paths[0]
#           apparently the Windows GUI appends .txt too, so this is redundant
#           if not match(r'\.txt$', path):
#              path = path + '.txt'
                # note (todo?): since this isn't integrated into
                # saveFileDialog, weird stuff can happen like if you
                # type /tmp/test, and there's already a /tmp/test, it'll
                # ask you if you want to overwrite it, but then if you confirm
                # it'll save to /tmp/test.txt

            f = open(path,'w')
            f.write(self.getMeetingMinutesString())
            f.close()
Exemplo n.º 17
0
 def on_menuFileSaveAs_select(self, event):
     if self.filename is None:
         path = ''
         filename = ''
     else:
         path, filename = os.path.split(self.filename)
     wildcard = "All files (*.*)|*.*"
     result = dialog.saveFileDialog(None, "Save As", path, filename,
                                    wildcard)
     if result.accepted:
         path = result.paths[0]
         fileType = graphic.bitmapType(path)
         #print fileType, path
         # should throw an error here if the user
         # tries to save as GIF since wxWindows doesn't
         # support that format due to licensing restrictions
         try:
             bmp = self.components.bufOff.getBitmap()
             bmp.SaveFile(path, fileType)
             return True
         except IOError:
             return False
     else:
         return False
Exemplo n.º 18
0
 def on_menuFileSaveAs_select(self, event):
     result = dialog.saveFileDialog(self, 'Save As', self.defaultPath(), '',
                                    '*.box')
     if result.accepted:
         path = result.paths[0]
         self.saveDrawing(path)

"""
This the Pythoncard interface.
Not using it now since py2exe is chocking on pythoncard
"""

from PythonCard import model
from PythonCard import dialog
import makeidf


class Minimal(model.Background):
    pass 
    
if __name__ == '__main__':
    app = model.Application(Minimal)
    wildcard = '*.txt'
    result = dialog.openFileDialog(wildcard=wildcard, style=dialog.wx.OPEN)
    if result.accepted:
        fname = result.paths[0]
        txt = open(fname, 'r').read()
        eplustxt = makeidf.makeidf(txt) 
    open('ee.idf', 'wb').write(eplustxt)
    wildcard = '*.idf'
    result = dialog.saveFileDialog(wildcard=wildcard)
    if result.accepted:
        fname = result.paths[0]
        open(fname, 'wb').write(eplustxt)
    app.Exit()
Exemplo n.º 20
0
 def on_menuFileSaveAs_select(self, event):
     result = dialog.saveFileDialog(self, 'Save As',
                                    self.defaultPath(), '', '*.box' )
     if result.accepted:
         path = result.paths[0]            
         self.saveDrawing(path)
Exemplo n.º 21
0
 def on_buttonSaveFile_mouseClick(self, event):
     wildcard = "JPG files (*.jpg;*.jpeg)|*.jpeg;*.JPG;*.JPEG;*.jpg|GIF files (*.gif)|*.GIF;*.gif|All Files (*.*)|*.*"
     # wildcard = '*.py'
     result = dialog.saveFileDialog(wildcard=wildcard)
     self.components.fldResults.text = "saveFileDialog result:\naccepted: %s\npaths: %s" % (
         result.accepted, result.paths)