示例#1
0
 def handleNewFromTemplate(self, instr_templ=''):
     new_instr_req = self.view.showNewInstrFromTemplateDialog(os.path.join(self.state.getWorkDir(), os.path.basename(str(instr_templ))))
     if new_instr_req != '':
         if self.view.closeCodeEditorWindow():
             text = McGuiUtils.getFileContents(instr_templ)
             new_instr = McGuiUtils.saveInstrumentFile(new_instr_req, text)
             self.state.loadInstrument(new_instr)
             self.emitter.status("Instrument created: " + os.path.basename(str(new_instr)))
示例#2
0
 def handleSaveAs(self):
     oldinstr = self.state.getInstrumentFile()
     if oldinstr != '':
         newinstr = self.view.showSaveAsDialog(oldinstr)
     
     if newinstr != '':
         self.state.unloadInstrument()
         text = McGuiUtils.getFileContents(oldinstr)
         created_instr = McGuiUtils.saveInstrumentFile(newinstr, text)
         if created_instr != '':
             self.state.loadInstrument(created_instr)
             self.emitter.status("Instrument saved as: " + newinstr)
示例#3
0
 def handleNewInstrument(self):
     new_instr_req = self.view.showNewInstrDialog(self.state.getWorkDir())
     if new_instr_req != '':
         template_text_header = open(os.path.join(mccode_config.configuration["MCCODE_LIB_DIR"], "examples", "template_header_simple.instr")).read()
         template_text_body = open(os.path.join(mccode_config.configuration["MCCODE_LIB_DIR"], "examples", "template_body_simple.instr")).read()
         new_instr = McGuiUtils.saveInstrumentFile(new_instr_req, template_text_header + template_text_body)
         if new_instr != '':
             if self.view.closeCodeEditorWindow():
                 self.state.unloadInstrument()
                 self.state.loadInstrument(new_instr)
                 self.view.showCodeEditorWindow(new_instr)
                 self.emitter.status("Editing new instrument: " + os.path.basename(str(new_instr)))
示例#4
0
 def saveInstrumentIfFileExists(self, text):
     instr = self.getInstrumentFile()
     if not os.path.exists(instr):
         return False
     McGuiUtils.saveInstrumentFile(instr, text)
     return True