Ejemplo n.º 1
0
 def onRename(self, e=None):
     if not self.filename:
         return
     newfile = tkSimpleDialog.askstring('Rename', 'Rename "%s" as?' % self.filename)
     if not newfile:
         return
     try:
         os.rename(emacro.getMacroPath(self.filename), emacro.getMacroPath(newfile))
     except OSError:    
         show_exc()
     else:    
         self.onRefresh() 
         self.setSelection(newfile)
Ejemplo n.º 2
0
 def onDelete(self, e=None):
     if not self.filename:
         return
     if tkMessageBox.askokcancel('Delete', 'Delete "%s"?' % self.filename):
         pathname = emacro.getMacroPath(self.filename)
         os.remove(pathname)
         self.onRefresh()    
Ejemplo n.º 3
0
 def onSave(self, event=None):
     try:
         data = self.script.getText()
         fp = file(emacro.getMacroPath(self.filename), 'w')
         fp.write(data)
         fp.close()
     except IOError:
         traceback.print_exc()
         return
Ejemplo n.º 4
0
 def open(self, filename):
     try:
         fp = file(emacro.getMacroPath(filename), 'r')
         data = fp.read()
         fp.close()
         self.script.setText(data)
         self.script.yview(0)
         self.scriptbox.setLabel(filename)
     except IOError:
         traceback.print_exc()
         return
Ejemplo n.º 5
0
 def onNew(self, e=None):
     newfile = tkSimpleDialog.askstring('New', 'Macro filename:')
     if not newfile:
         return
     pathname = emacro.getMacroPath(newfile)
     if os.path.exists(pathname):
         tkMessageBox.showerror('Error', 'Duplicated file "%s"!' % pathname)
         return
     
     fp = file(pathname, 'w')
     fp.write(emacro.getMacroTemplate())
     fp.close()
     self.onRefresh()
     self.setSelection(newfile)
     
     em = EditMacro(self.master, newfile)