當前位置: 首頁>>代碼示例>>Python>>正文


Python PyMcaGui.PyMcaFileDialogs類代碼示例

本文整理匯總了Python中PyMca5.PyMcaGui.PyMcaFileDialogs的典型用法代碼示例。如果您正苦於以下問題:Python PyMcaFileDialogs類的具體用法?Python PyMcaFileDialogs怎麽用?Python PyMcaFileDialogs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PyMcaFileDialogs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _getFileList

    def _getFileList(self, fileTypeList, message=None, getfilter=None):
        if message is None:
            message = "Please select a file"
        if getfilter is None:
            getfilter = False
        wdir = PyMcaDirs.inputDir
        filterused = None
        if getfilter:
            filelist, filterused = PyMcaFileDialogs.getFileList(self.parent,
                            filetypelist=fileTypeList,
                            mode="OPEN",
                            message=message,
                            currentdir=wdir,
                            getfilter=True,
                            single=False,
                            native=True)
        else:
            filelist = PyMcaFileDialogs.getFileList(self.parent,
                            filetypelist=fileTypeList,
                            mode="OPEN",
                            message=message,
                            currentdir=wdir,
                            getfilter=False,
                            single=False,
                            native=True)
        if not(len(filelist)):
            return []
        PyMcaDirs.inputDir = os.path.dirname(filelist[0])
        if PyMcaDirs.outputDir is None:
            PyMcaDirs.outputDir = os.path.dirname(filelist[0])

        if getfilter:
            return filelist, filterused
        else:
            return filelist
開發者ID:marcus-oscarsson,項目名稱:pymca,代碼行數:35,代碼來源:StackSelector.py

示例2: loadButtonClicked

 def loadButtonClicked(self):
     if self.inputDir is None:
         if self.inputDir is not None:
             self.inputDir = self.outputDir
         else:
             self.inputDir = PyMcaDirs.inputDir
     wdir = self.inputDir
     if not os.path.exists(wdir):
         wdir = os.getcwd()
     filename = PyMcaFileDialogs.getFileList(self,
                         filetypelist=["Energy table files (*.csv)"],
                         mode="OPEN",
                         message="Choose energy table file",
                         currentdir=wdir,
                         single=True)
     if len(filename):
         filename = qt.safe_str(filename[0])
         if len(filename):
             try:
                 self.loadEnergyTableParameters(filename)
                 self.inputDir = os.path.dirname(filename)
                 PyMcaDirs.inputDir = self.inputDir
             except:
                 msg = qt.QMessageBox(self)
                 msg.setIcon(qt.QMessageBox.Critical)
                 msg.setText("Error loading energy table: %s" % (sys.exc_info()[1]))
                 msg.exec_()
開發者ID:dnaudet,項目名稱:pymca,代碼行數:27,代碼來源:EnergyTable.py

示例3: browseFitConfiguration

 def browseFitConfiguration(self):
     if self._inputDir is None:
         self._inputDir = PyMcaDirs.inputDir
     elif os.path.exists(self._inputDir):
         PyMcaDirs.inputDir = self._inputDir
     filetypes  = ["Configuration Files (*.cfg)"]
     if self._inputDir is None:
         self._inputDir = PyMcaDirs.inputDir
     elif os.path.exists(self._inputDir):
         PyMcaDirs.inputDir = self._inputDir
     message = "Select a Simple Fit Configuration File"
     mode = "OPEN"
     getfilter = False
     currentfilter = None #self._lastInputFileFilter
     fileList = PyMcaFileDialogs.getFileList(self,
                                              filetypelist=filetypes,
                                              message=message,
                                              mode=mode,
                                              getfilter=getfilter,
                                              single=True,
                                              currentfilter=currentfilter)
     if not len(fileList):
         return
     self._inputDir = os.path.dirname(fileList[0])
     self.setFitConfigurationFile(fileList[0])
     self.raise_()
開發者ID:dnaudet,項目名稱:pymca,代碼行數:26,代碼來源:SimpleFitBatchGui.py

示例4: _getOutputTiffFilename

 def _getOutputTiffFilename(self):
     fileTypes = "TIFF Files (*.tif *.tiff *.TIF *.TIFF)"
     message = "Enter output filename"
     wdir = PyMcaDirs.outputDir
     filename = PyMcaFileDialogs.getFileList(self,
                                     message=message,
                                     mode="SAVE",
                                     currentdir=wdir,
                                     filetypelist=[fileTypes],
                                     getfilter=False,
                                     single=True)
     if len(filename):
         filename = filename[0]
     if len(filename):
         try:
             fname = qt.safe_str(filename)
             if fname.endswith('.tif') or\
                fname.endswith('.tiff') or\
                fname.endswith('.TIF') or\
                fname.endswith('.TIFF'):
                 return fname
             else:
                 return fname + ".tif"
         except UnicodeEncodeError:
             msg = qt.QMessageBox(self)
             msg.setWindowTitle("Encoding error")
             msg.setIcon(qt.QMessageBox.Critical)
             msg.setText("Please use ASCII characters in file name and path")
             msg.exec_()
     return ""
開發者ID:aaron-parsons,項目名稱:pymca,代碼行數:30,代碼來源:QStackWidget.py

示例5: saveSignal

 def saveSignal(self):
     fileList = PyMcaFileDialogs.getFileList(self,
                                             filetypelist=['cfg file (*.cfg)'],
                                             mode="SAVE",
                                             single=True,
                                             getfilter=False)
     if len(fileList):
         self.saveConfiguration(fileList[0])
開發者ID:vasole,項目名稱:pymca,代碼行數:8,代碼來源:XASSelfattenuationWindow.py

示例6: browseConfigurationFile

 def browseConfigurationFile(self):
     f = PyMcaFileDialogs.getFileList(parent=self,
                                  filetypelist=["Configuration files (*.cfg)"],
                                  message="Open a fit configuration file",
                                  mode="OPEN",
                                  single=True)
     if len(f):
         self._configLine.setText(f[0])
開發者ID:maurov,項目名稱:pymca,代碼行數:8,代碼來源:FastXRFLinearFitWindow.py

示例7: saveImage

 def saveImage(self):
     filelist = PyMcaFileDialogs.getFileList(
         parent=self,
         filetypelist=["Image files (*.png)"],
         message="Please give output file name",
         mode="SAVE",
         getfilter=False)
     if len(filelist):
         self.glWidget.saveImage(filelist[0])
開發者ID:PiRK,項目名稱:pymca,代碼行數:9,代碼來源:SceneGLWindow.py

示例8: load

 def load(self):
     fileList = PyMcaFileDialogs.getFileList(parent=self,
                                             filetypelist=["Fit files (*.cfg)"],
                                             message="Select a fit configuration file",
                                             mode="OPEN",
                                             getfilter=False,
                                             single=True)
     if len(fileList):
         d = ConfigDict.ConfigDict()
         d.read(fileList[0])
         self.setParameters(d)
開發者ID:maurov,項目名稱:pymca,代碼行數:11,代碼來源:StrategyHandler.py

示例9: browseFile

 def browseFile(self):
     filelist = PyMcaFileDialogs.getFileList(self,
                             filetypelist=['HDF5 files (*.h5)'],
                             message="Please enter output file",
                             mode="SAVE",
                             single=True)
     if len(filelist):
         name = filelist[0]
         if not name.endswith('.h5'):
             name = name + ".h5"
         self.fileName.setText(name)
開發者ID:dnaudet,項目名稱:pymca,代碼行數:11,代碼來源:FFTAlignmentWindow.py

示例10: getObject3DInstance

def getObject3DInstance(config=None):
    #for the time being a former configuration
    #for serializing purposes is not implemented

    #I do the import here for the case PyMca is not installed
    #because the modules could be instanstiated without using
    #this method
    try:
        from PyMca5.PyMcaIO import EDFStack
        from PyMca5.PyMcaIO import TiffStack
    except ImportError:
        import EDFStack
        import TiffStack

    fileTypeList = ['EDF Z Stack (*edf *ccd)',
                    'EDF X Stack (*edf *ccd)',
                    'TIFF Stack (*tif *tiff)']
    old = PyMcaFileDialogs.PyMcaDirs.nativeFileDialogs * 1
    PyMcaFileDialogs.PyMcaDirs.nativeFileDialogs = False
    fileList, filterUsed = PyMcaFileDialogs.getFileList(
        parent=None,
        filetypelist=fileTypeList,
        message="Please select the object file(s)",
        mode="OPEN",
        getfilter=True)
    PyMcaFileDialogs.PyMcaDirs.nativeFileDialogs = old
    if not len(fileList):
        return None
    if filterUsed == fileTypeList[0]:
        fileindex = 2
    else:
        fileindex = 1
    #file index is irrelevant in case of an actual 3D stack.
    filename = fileList[0]
    legend = os.path.basename(filename)
    if filterUsed == fileTypeList[2]:
        #TIFF
        stack = TiffStack.TiffStack(dtype=numpy.float32, imagestack=False)
        stack.loadFileList(fileList, fileindex=1)
    elif len(fileList) == 1:
        stack = EDFStack.EDFStack(dtype=numpy.float32, imagestack=False)
        stack.loadIndexedStack(filename, fileindex=fileindex)
    else:
        stack = EDFStack.EDFStack(dtype=numpy.float32, imagestack=False)
        stack.loadFileList(fileList, fileindex=fileindex)
    if stack is None:
        raise IOError("Problem reading stack.")
    object3D = Object3DStack(name=legend)
    object3D.setStack(stack)
    return object3D
開發者ID:PiRK,項目名稱:pymca,代碼行數:50,代碼來源:Object3DStack.py

示例11: saveParameters

 def saveParameters(self, fname=None):
     if fname is None:
         fname = PyMcaFileDialogs.getFileList(self,
                                      filetypelist=["Configuration (*.ini)",
                                                    "Configuration (*.cfg)"],
                                      message="Please enter output file name",
                                      mode="SAVE",
                                      getfilter=False,
                                      single=True)
         if len(fname):
             fname = fname[0]
         else:
             return
     ddict = ConfigDict.ConfigDict()
     ddict["XASParameters"] = self.getParameters()
     ddict.write(fname)
開發者ID:maurov,項目名稱:pymca,代碼行數:16,代碼來源:XASParameters.py

示例12: loadParameters

 def loadParameters(self, fname=None):
     if fname is None:
         fname = PyMcaFileDialogs.getFileList(self,
                                      filetypelist=["Configuration (*.ini)",
                                                    "Configuration (*.cfg)",
                                                    "All files (*)"],
                                      message="Please set input file name",
                                      mode="OPEN",
                                      getfilter=False,
                                      single=True)
         if len(fname):
             fname = fname[0]
         else:
             return
     d = ConfigDict.ConfigDict()
     d.read(fname)
     self.setParameters(d["XASParameters"])
開發者ID:maurov,項目名稱:pymca,代碼行數:17,代碼來源:XASParameters.py

示例13: browseOutputDirectory

 def browseOutputDirectory(self):
     if self._outputDir is None:
         self._outputDir = PyMcaDirs.outputDir
     elif os.path.exists(self._outputDir):
         PyMcaDirs.inputDir = self._outputDir
     message = "Select a Simple Fit Configuration File"
     mode = "OPEN"
     fileList = PyMcaFileDialogs.getExistingDirectory(self,
                                              message=message,
                                              mode=mode)
     if not len(fileList):
         return
     if type(fileList) != type([]):
         fileList = [fileList]
     self._outputDir = os.path.dirname(fileList[0])
     self.setOutputDirectory(fileList[0])
     self.raise_()
開發者ID:dnaudet,項目名稱:pymca,代碼行數:17,代碼來源:SimpleFitBatchGui.py

示例14: funevent

 def funevent(self,item):
     item=str(item)
     if item in self.specfit.theorylist:
         self.specfit.settheory(item)
     else:
         filelist = PyMcaFileDialogs.getFileList(self,
                      message="Select python module with your function(s)",
                      filetypelist=["Python Files (*.py)",
                                    "All Files (*)"],
                      mode="OPEN",
                      single=True,
                      getfilter=False)
                             
         if not len(filelist):           
             functionsfile = ""
         else:
             functionsfile = filelist[0]
         if len(functionsfile):
             try:
                 if self.specfit.importfun(functionsfile):
                     qt.QMessageBox.critical(self, "ERROR",
                                             "Function not imported")
                     return
                 else:
                     #empty the ComboBox
                     n=self.guiconfig.FunComBox.count()
                     while(self.guiconfig.FunComBox.count()>1):
                       self.guiconfig.FunComBox.removeItem(1)
                     #and fill it again
                     for key in self.specfit.theorylist:
                         if QTVERSION < '4.0.0':
                             self.guiconfig.FunComBox.insertItem(str(key))
                         else:
                             self.guiconfig.FunComBox.addItem(str(key))
             except:
                 qt.QMessageBox.critical(self, "ERROR",
                                         "Function not imported")
         i=1+self.specfit.theorylist.index(self.specfit.fitconfig['fittheory'])
         if QTVERSION < '4.0.0':
             self.guiconfig.FunComBox.setCurrentItem(i)
         else:
             self.guiconfig.FunComBox.setCurrentIndex(i)
     self.__initialparameters()
     return
開發者ID:vasole,項目名稱:pymca,代碼行數:44,代碼來源:SpecfitGui.py

示例15: browseList

 def browseList(self):
     if self._inputDir is None:
         self._inputDir = PyMcaDirs.inputDir
     elif os.path.exists(self._inputDir):
         PyMcaDirs.inputDir = self._inputDir
     filetypes  = ["Mca Files (*.mca)",
                   "Edf Files (*.edf)"]
     if HDF5SUPPORT:
         filetypes.append("HDF5 Files(*.nxs *.h5 *.hdf)")
     filetypes.append("SPEC Files (*.spec)")
     filetypes.append("SPEC Files (*.dat)")
     filetypes.append("All files (*)")
     message = "Open a set of files"
     mode = "OPEN"
     getfilter = True
     currentfilter = self._lastInputFileFilter
     fileList, fileFilter  = PyMcaFileDialogs.getFileList(self,
                                              filetypelist=filetypes,
                                              message=message,
                                              mode=mode,
                                              getfilter=getfilter,
                                              single=False,
                                              currentfilter=currentfilter)
     if not len(fileList):
         return
     else:
         self._lastInputFileFilter = fileFilter
     self._inputDir = os.path.dirname(fileList[0])
     if (QTVERSION < '4.2.0') or (not len(self._fileList)):
         self.setFileList(fileList)
         self.raise_()
         return
     msg = qt.QMessageBox()
     msg.setWindowTitle("Append or replace")
     msg.setIcon(qt.QMessageBox.Information)
     msg.setText("Do you want to delete current file list?")
     msg.setStandardButtons(qt.QMessageBox.Yes|qt.QMessageBox.No)
     answer=msg.exec_()
     if answer == qt.QMessageBox.Yes:
         append = False
     else:
         append = True
     self.setFileList(fileList, append=append)
     self.raise_()
開發者ID:dnaudet,項目名稱:pymca,代碼行數:44,代碼來源:SimpleFitBatchGui.py


注:本文中的PyMca5.PyMcaGui.PyMcaFileDialogs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。