def importFastaSeq(self): if not self.project: showWarning('Failure','Please create a new CCPN project.', parent=self) return fileTypes = [ FileType('Fasta', ['*.fsa']), FileType('All', ['*']) ] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Import Fasta sequence file', dismiss_text='Cancel', selected_file_must_exist=True, multiSelect=False,) fileName = fileSelectPopup.getFile() if not os.path.exists(fileName): showWarning('Failure','No such file.', parent=self) return if fileName: name = os.path.split(fileName)[1] if '.' in name: name = name.split('.')[0] fastaObj = FastaFormat(self.project, self, verbose=True) fastaObj.readSequence(fileName, minimalPrompts=True) self.eciFrame.updateAll() return fastaObj
def importPdb(self): if not self.project: showWarning('Failure','Please create a new CCPN project.', parent=self) return fileTypes = [ FileType('PDB', ['*.pdb']), FileType('PDB Entry', ['*.ent']), FileType('All', ['*']) ] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Import PDB 3.20 file', dismiss_text='Cancel', selected_file_must_exist=True, multiSelect=False,) fileName = fileSelectPopup.getFile() if not os.path.exists(fileName): showWarning('Failure','No such file.', parent=self) return if fileName: name = os.path.split(fileName)[1] if '.' in name: name = name.split('.')[0] pdbObj = ReadPdb(fileName, self.project, 'PDB_'+ name, self) self.eciFrame.updateAll() return pdbObj
def chooseOldProjectFile(self): fileTypes = [ FileType('CING', ['project.xml']), FileType('All', ['*']) ] popup = FileSelectPopup(self, file_types = fileTypes, title = 'Select CING project file', dismiss_text = 'Cancel', selected_file_must_exist = True) fileName = popup.getFile() # dirName = popup.getDirectory() if len(fileName) > 0: # Put text into entry,name widgets dummy,name = cing.Project.rootPath(fileName) self.projEntry.configure(state='normal') self.projEntry.set(fileName) self.nameEntry.configure(state='normal') self.nameEntry.set(name) self.nameEntry.configure(state='disabled') # choose the correct radiobutton self.projOptionsSelect.setIndex(0) self.updateGui() # end if #nd if popup.destroy()
def importPdbCoords(self): if not self.project: showWarning('Failure','Please create a new CCPN project.', parent=self) return fileTypes = [ FileType('PDB', ['*.pdb']), FileType('PDB Entry', ['*.ent']), FileType('All', ['*']) ] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Import PDB coordinates file', dismiss_text='Cancel', selected_file_must_exist=True, multiSelect=False,) fileName = fileSelectPopup.getFile() if not os.path.exists(fileName): showWarning('Failure','No such file.', parent=self) return if fileName: name = os.path.split(fileName)[1] if '.' in name: name = name.split('.')[0] pdbObj = PseudoPdbFormat(self.project, self, verbose=True) pdbObj.readCoordinates(fileName, minimalPrompts=True) self.eciFrame.updateAll() return pdbObj
def importNmrStar31(self): if not self.project: showWarning('Failure','Please create a new CCPN project.', parent=self) return fileTypes = [ FileType('STAR', ['*.str']), FileType('All', ['*'])] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Import NMR-STAR 3.1 file', dismiss_text='Cancel', selected_file_must_exist=True, multiSelect=False,) fileName = fileSelectPopup.getFile() if not os.path.exists(fileName): showWarning('Failure','No such file.', parent=self) return if fileName: nmrStarObj = NmrStarFormat(self.project, self, verbose=True) nmrStarObj.readProject(fileName, minimalPrompts=True, version='3.1') self.eciFrame.updateAll() return nmrStarObj
def import_project(self): # FIXME JMCI # need to preserve the current status. Take default from the # Wms layer rootDir = self.basePopup.repList.current_import_dir fileSelectPopup = FileSelectPopup(self, None, rootDir) new_project_dir = fileSelectPopup.getDirectory() self.basePopup.repList.current_import_dir = new_project_dir print 'in import project with directory', new_project_dir idx = new_project_dir.rfind('/') new_project_name = new_project_dir[idx + 1:] print 'in import project with project', new_project_name # FIXME # need to set the project version number somewhere. For now set to none # and this gets picked up and set to a default 1.1 later self.repository.import_project(new_project_name, None, new_project_dir) self.drawFrame()
def chooseOldProjectFile(self): fileTypes = [FileType('CING', ['project.xml']), FileType('All', ['*'])] popup = FileSelectPopup(self, file_types=fileTypes, title='Select CING project file', dismiss_text='Cancel', selected_file_must_exist=True) fileName = popup.getFile() # dirName = popup.getDirectory() if len(fileName) > 0: # Put text into entry,name widgets dummy, name = cing.Project.rootPath(fileName) self.projEntry.configure(state='normal') self.projEntry.set(fileName) self.nameEntry.configure(state='normal') self.nameEntry.set(name) self.nameEntry.configure(state='disabled') # choose the correct radiobutton self.projOptionsSelect.setIndex(0) self.updateGui() # end if #nd if popup.destroy()
def exportText(self, *event): from memops.gui.FileSelect import FileType from memops.gui.FileSelectPopup import FileSelectPopup if self.textOut: fileTypes = [ FileType('Text', ['*.txt']), FileType('CSV', ['*.csv']), FileType('All', ['*']) ] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Save table as text', dismiss_text='Cancel', selected_file_must_exist=False) fileName = fileSelectPopup.getFile() if fileName: file = open(fileName, 'w') if fileName.endswith('.csv'): for textRow in self.textMatrix: file.write(','.join(textRow) + '\n') else: file.write(self.textOut)
def selectFile(self): fileSelectPopup = FileSelectPopup(self, title = 'Choose file', dismiss_text = 'Cancel', selected_file_must_exist = True) fileName = fileSelectPopup.getFile() self.textWindow.setText('File Selected: %s\n' % fileName)
def selectDir(self): popup = FileSelectPopup(self, show_file=False) dir = popup.getDirectory() popup.destroy() if (dir): self.dir_entry.set(dir) self.setDir()
def chooseExecutable(self): fileTypes = [FileType('Table', ['*.exe']), FileType('All', ['*'])] fileSelectPopup = FileSelectPopup(self, file_types = fileTypes, title = 'Choose 2d BACUS executable', dismiss_text = 'Cancel', selected_file_must_exist = False) fileName = fileSelectPopup.getFile() if fileName: self.executableEntry.set(fileName)
def getDirectory(self, widget, obj, attrName): """Is called by updateGeneral. No widget because table placement is irrelevent and setting process not interruptable""" value = getattr(obj, attrName) if not os.path.exists(value): value = None popup = FileSelectPopup(self, directory=value, show_file=False) value = popup.getDirectory() if value: setattr(obj, attrName, value)
def selectWorkingDir(self): popup = FileSelectPopup(self, show_file=False) directory = popup.getDirectory() if directory: self.workingDirEntry.set(directory) popup.destroy() self.updateAfter()
def selectTempDir(self): popup = FileSelectPopup(self, show_file=False) directory = popup.getDirectory() if directory: self.tempDirEntry.set( directory ) popup.destroy() self.updateEntryParams()
def selectExecutable(self): """ Choose the MODULE executable appropriate for your system. """ popup = FileSelectPopup(self, show_file=True) executable = popup.getFile() if executable: self.moduleExeEntry.set(executable) popup.destroy()
def chooseMiscScript(self): # Prepend default Cyana file extension below fileTypes = [ FileType('All', ['*']), ] popup = FileSelectPopup(self, file_types = fileTypes, title = 'Script file', dismiss_text = 'Cancel', selected_file_must_exist = True) fileName = popup.getFile() self.miscScriptEntry.set(fileName) popup.destroy()
def chooseDirectory(self): directory = os.path.dirname(self.fileName) if not directory: directory = os.getcwd() popup = FileSelectPopup(self, directory=directory, show_file=False) directory = popup.getDirectory() popup.destroy() if directory: self.directoryEntry.set(directory)
def chooseValidScript(self): # Prepend default Cyana file extension below fileTypes = [ FileType('Python', ['*.py']), ] popup = FileSelectPopup(self, file_types = fileTypes, title='Python file', dismiss_text='Cancel', selected_file_must_exist = True) fileName = popup.getFile() self.validScriptEntry.set(fileName) popup.destroy()
def chooseZipFile(self): fileTypes = [ FileType('Zip', ['*.zip']), ] popup = FileSelectPopup(self, file_types=fileTypes, file=self.resultFileEntry.get(), title='Results zip file location', dismiss_text='Cancel', selected_file_must_exist=False) fileName = popup.getFile() if fileName: self.resultFileEntry.set(fileName) popup.destroy()
def selectFile(self): spectrum = self.spectrum if spectrum: directory = spectrum.analysisSpectrum.contourDir.dataLocation else: directory = os.getcwd() popup = FileSelectPopup(self, directory=directory) fileName = popup.getFile() popup.destroy() if fileName: self.file_entry.set(fileName)
def chooseFile(self): directory = self.directoryEntry.get() if not directory: directory = os.getcwd() popup = FileSelectPopup(self, directory=directory) file = popup.getFile() popup.destroy() if file: template = os.path.basename(file) self.templateEntry.set(template)
def chooseCyanaFile(self): # Prepend default Cyana file extension below fileTypes = [ FileType('All', ['*']), ] popup = FileSelectPopup(self, file_types = fileTypes, title = 'CYANA fproject file', dismiss_text = 'Cancel', selected_file_must_exist = True) fileName = popup.getFile() self.cyanaEntry.set(fileName) self.projOptionsSelect.setIndex(3) popup.destroy()
def findFile(self): if self.file_select_popup: self.file_select_popup.open() else: file_types = [ FileType('All', ['*']), FileType('PostScript', ['*.ps', '*.eps']), FileType('PDF', ['*.pdf', '*.ai']) ] self.file_select_popup = FileSelectPopup(self, file_types=file_types) file = self.file_select_popup.getFile() if file: self.file_entry.set(file)
def selectCnsExe(self): fileTypes = [ FileType("All", ["*"]), FileType("EXE", ["*.exe"]) ] popup = FileSelectPopup(self, fileTypes) file = popup.getFile() if file: self.cnsExeEntry.set( file ) popup.destroy() self.updateEntryParams()
def askFile(title, prompt, initial_value = '', parent = None, dismiss_text='Cancel', extra_dismiss_text = ''): if (parent): popup = FileSelectPopup(parent, title=title, prompt=prompt, show_file=True, dismiss_text=dismiss_text, extra_dismiss_text=extra_dismiss_text, file=initial_value) file = popup.getFile() popup.destroy() return file else: return askString(title, prompt, initial_value)
def askDir(title, prompt, initial_value = '', parent = None, dismiss_text='Cancel', extra_dismiss_text = '', default_dir = None): if (parent): popup = FileSelectPopup(parent, title=title, prompt=prompt, show_file=False, dismiss_text=dismiss_text, extra_dismiss_text=extra_dismiss_text, file=initial_value, default_dir = default_dir) dir = popup.getDirectory() popup.destroy() return dir else: return askString(title, prompt, initial_value)
def readPCSFileChange(self): fileTypes = [FileType('PCS', ['*.npc']), FileType('All', ['*'])] fileSelectPopup = FileSelectPopup( self, file=os.path.basename(self.calPCSEntry.get()), directory=os.path.dirname(self.calPCSEntry.get()), file_types=fileTypes, title='Save PCS values to file', dismiss_text='Cancel', selected_file_must_exist=False, multiSelect=False, ) self.calPCSEntry.set(fileSelectPopup.getFile())
def writeScriptFileChange(self): fileTypes = [FileType('python', ['*.py']), FileType('All', ['*'])] fileSelectPopup = FileSelectPopup( self, file=os.path.basename(self.scriptEntry.get()), directory=os.path.dirname(self.scriptEntry.get()), file_types=fileTypes, title='Paramagpy script', dismiss_text='Cancel', selected_file_must_exist=False, multiSelect=False, ) self.scriptEntry.set(fileSelectPopup.getFile())
def printCanvas(self, *event): fileTypes = [ FileType('PostScript', ['*.ps']), FileType('All', ['*'])] fileSelectPopup = FileSelectPopup(self, file_types = fileTypes, title = 'Print canvas to file', dismiss_text = 'Cancel', selected_file_must_exist = False) fileName = fileSelectPopup.getFile() self.bbox = bbox = self.canvas.bbox('all') w = bbox[2] - bbox[0] h = bbox[3] - bbox[1] self.canvas.postscript(colormode='color',file=fileName, x=bbox[0], y=bbox[1], width=w+2, pagewidth='21.c', height=h+2, fontmap='fontmap')
def printCanvas(self, *event): from memops.gui.FileSelect import FileType from memops.gui.FileSelectPopup import FileSelectPopup fileTypes = [FileType('PostScript', ['*.ps']), FileType('All', ['*'])] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Print canvas to file', dismiss_text='Cancel', selected_file_must_exist=False) fileName = fileSelectPopup.getFile() self.postscript(colormode='color', file=fileName)
def getDataUrl(self, *extra): if self.dataStore: dataStore = self.dataStore oldPath = dataStore.dataUrl.url.dataLocation if os.path.exists(oldPath): directory = oldPath elif os.path.exists(os.path.dirname(oldPath)): directory = os.path.dirname(oldPath) else: directory = None popup = FileSelectPopup(self, directory=directory, show_file=False) newPath = popup.getDirectory() popup.destroy() if newPath and oldPath != newPath: changeDataStoreUrl(dataStore, newPath)
def findFile(self): format = self.format_menu.getSelected() if (format == tabFormat): file_types = [FileType('All', ['*']), FileType('Text', ['*.txt'])] else: file_types = [FileType('All', ['*']), FileType('CSV', ['*.csv'])] popup = FileSelectPopup(self, file_types=file_types) file = popup.getFile() if (file): self.file_entry.set(file) popup.destroy()
def loadValues(self): directory = self.parent.fileSelect.getDirectory() fileSelectPopup = FileSelectPopup(self, title='Select Sampled Data File', dismiss_text='Cancel', selected_file_must_exist=True, multiSelect=False, directory=directory) fileName = fileSelectPopup.file_select.getFile() if not fileName: return fileObj = open(fileName, 'rU') data = '' line = fileObj.readline() while line: data += line line = fileObj.readline() fileObj.close() data = re.sub(',\s+', ',', data) data = re.sub('\s+', ',', data) data = re.sub(',,', ',', data) data = re.sub('[^0-9,.\-+eE]', '', data) self.valueEntry.set(data)
def chooseCcpnFile(self): fileTypes = [ FileType('XML', ['*.xml']), FileType('All', ['*'])] popup = FileSelectPopup(self, file_types = fileTypes, title = 'CCPN project XML file', dismiss_text = 'Cancel', selected_file_must_exist = True) fileName = popup.getFile() if len(fileName)>0: self.pdbEntry.configure(state='normal') self.pdbEntry.set(fileName) self.projOptionsSelect.setIndex(1) _dir,name,dummy = nTpath( fileName ) self.nameEntry.set(name) #end if self.ccpnEntry.set(fileName) self.projOptionsSelect.setIndex(2) popup.destroy()
def choosePdbFile(self): fileTypes = [ FileType('PDB', ['*.pdb']), FileType('All', ['*'])] popup = FileSelectPopup(self, file_types = fileTypes, title = 'PDB file', dismiss_text = 'Cancel', selected_file_must_exist = True) fileName = popup.getFile() if len(fileName)>0: # Put text into entry widget self.pdbEntry.configure(state='normal') self.pdbEntry.set(fileName) # Put text into name widget _dir,name,dummy = nTpath( fileName ) self.nameEntry.configure(state='normal') self.nameEntry.set(name) # choose the correct radiobutton self.projOptionsSelect.setIndex(1) self.updateGui() #end if popup.destroy()