本文整理汇总了Python中PyMca5.PyMcaGui.PyMcaFileDialogs.getFileList方法的典型用法代码示例。如果您正苦于以下问题:Python PyMcaFileDialogs.getFileList方法的具体用法?Python PyMcaFileDialogs.getFileList怎么用?Python PyMcaFileDialogs.getFileList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyMca5.PyMcaGui.PyMcaFileDialogs
的用法示例。
在下文中一共展示了PyMcaFileDialogs.getFileList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getFileList
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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
示例2: loadButtonClicked
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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_()
示例3: browseFitConfiguration
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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_()
示例4: _getOutputTiffFilename
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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 ""
示例5: saveSignal
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
def saveSignal(self):
fileList = PyMcaFileDialogs.getFileList(self,
filetypelist=['cfg file (*.cfg)'],
mode="SAVE",
single=True,
getfilter=False)
if len(fileList):
self.saveConfiguration(fileList[0])
示例6: browseConfigurationFile
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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])
示例7: saveImage
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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])
示例8: load
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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)
示例9: browseFile
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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)
示例10: getObject3DInstance
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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
示例11: saveParameters
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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)
示例12: loadParameters
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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"])
示例13: funevent
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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
示例14: browseList
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
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_()
示例15: getObject3DInstance
# 需要导入模块: from PyMca5.PyMcaGui import PyMcaFileDialogs [as 别名]
# 或者: from PyMca5.PyMcaGui.PyMcaFileDialogs import getFileList [as 别名]
def getObject3DInstance(config=None):
fileTypeList = ['Picture Files (*jpg *jpeg *tif *tiff *png)',
'EDF Files (*edf)',
'EDF Files (*ccd)',
'ADSC Files (*img)',
'EDF Files (*)']
fileList, filterUsed = PyMcaFileDialogs.getFileList(
parent=None,
filetypelist=fileTypeList,
message="Please select one object data file",
mode="OPEN",
getfilter=True)
if not len(fileList):
return
fname = fileList[0]
if filterUsed.split()[0] == "Picture":
qimage = qt.QImage(fname)
if qimage.isNull():
msg = qt.QMessageBox(self)
msg.setIcon(qt.QMessageBox.Critical)
msg.setText("Cannot read file %s as an image" % fname)
msg.exec_()
return
object3D = Object3DPixmap(os.path.basename(fname))
object3D.setQImage(qimage)
return object3D
if filterUsed.split()[0] in ["EDF", "ADSC"]:
edf = EdfFile.EdfFile(fname)
data = edf.GetData(0)
if True:
object3D = Object3DPixmap(os.path.basename(fname))
object3D.setImageData(data)
else:
(image,size,minmax)= spslut.transform(data, (1,0),
(spslut.LINEAR,3.0),
"RGBX", spslut.TEMP,
1,
(0, 1),
(0, 255), 1)
object3D = Object3DPixmap(os.path.basename(fname))
object3D.setPixmap(image, size[0], size[1], xmirror = False, ymirror = False)
return object3D
return None