本文整理汇总了Python中PyQt5.QtCore.QFileInfo.isFile方法的典型用法代码示例。如果您正苦于以下问题:Python QFileInfo.isFile方法的具体用法?Python QFileInfo.isFile怎么用?Python QFileInfo.isFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QFileInfo
的用法示例。
在下文中一共展示了QFileInfo.isFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import isFile [as 别名]
def save(self, *args):
l = len(args)
if l==0:
args = ('')
if l==1:
arg = args[0]
file = QFileInfo(arg)
if not file.isFile():
fileName = self.fileName()
error = args[0]
else:
fileName = arg
error = ''
return self.save(fileName, error)
if l==2:
##
# Saves the map to the file at \a fileName. Returns whether or not the
# file was saved successfully. If not, <i>error</i> will be set to the
# error message if it is not 0.
#
# If the save was successful, the file name of this document will be set
# to \a fileName.
#
# The map format will be the same as this map was opened with.
##
fileName, error = args
mapFormat = self.mWriterFormat
tmxMapFormat = TmxMapFormat()
if (not mapFormat):
mapFormat = tmxMapFormat
if (not mapFormat.write(self.map(), fileName)):
if (error):
error = mapFormat.errorString()
return False
self.undoStack().setClean()
self.setFileName(fileName)
self.mLastSaved = QFileInfo(fileName).lastModified()
self.saved.emit()
return True
示例2: open
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import isFile [as 别名]
def open(self, t_filename=None):
settings = QSettings(QSettings.IniFormat, QSettings.UserScope, "pySPM", "pySPM")
if t_filename is None:
home = QDir.cleanPath(os.getenv("HOMEPATH"))
path = settings.value("lastPath", home)
self.filename = QFileDialog.getOpenFileName(None, "Choose measurement file", path, "*.ita")
else:
self.filename = t_filename
check_file = QFileInfo(self.filename)
self.setWindowTitle(check_file.fileName())
if not check_file.exists() or not check_file.isFile():
return
settings.setValue("lastPath", check_file.path())
self.ita = pySPM.ITA(self.filename)
self.t, self.S = self.ita.getSpectrum(time=True)
self.sf, self.k0 = self.ita.get_mass_cal()
self.mass = pySPM.utils.time2mass(self.t, self.sf, self.k0)
self.spec = self.ax.plot(self.mass, self.S)[0]
SatLevel = self.ita.size['pixels']['x']*self.ita.size['pixels']['y']*self.ita.Nscan
self.sat_level = self.ax.axhline(SatLevel, color='r')
if 'pySPM' in self.ita.root.goto("MassScale"):
self.MassCal = []
N = self.ita.root.goto("MassScale/pySPM/N").get_ulong()
for i in range(N):
elt = self.ita.root.goto("MassScale/pySPM/"+str(i)+"/elt").value.decode('utf8')
mass = self.ita.root.goto("MassScale/pySPM/"+str(i)+"/mass").get_double()
time = self.ita.root.goto("MassScale/pySPM/"+str(i)+"/time").get_double()
self.MassCal.append(dict(elt=elt, mass=mass, time=time))
else:
self.MassCal = []
for x in self.ita.root.goto("MassScale/calib"):
if x.name == 'assign':
self.MassCal.append({'elt':x.get_string()})
if x.name == 'mcp':
mcp = struct.unpack("<10d", x.value)
self.MassCal[-1]['time'] = mcp[0]
self.MassCal[-1]['mass'] = mcp[1]
self.DoMassCal()
示例3: __init__
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import isFile [as 别名]
def __init__(self, path, parent = None):
super().__init__(parent)
self.mPath = path
self.mUi = Ui_NewTilesetDialog()
self.mNameWasEdited = False
self.mUi.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
# Restore previously used settings
s = preferences.Preferences.instance().settings()
tilesetType = s.value(TYPE_KEY, 0)
colorEnabled = bool(s.value(COLOR_ENABLED_KEY))
colorName = s.value(COLOR_KEY, '')
if colorName == '':
color = Qt.magenta
else:
color = QColor(colorName)
spacing = s.value(SPACING_KEY, 0)
margin = s.value(MARGIN_KEY, 0)
self.mUi.tilesetType.setCurrentIndex(tilesetType)
self.mUi.useTransparentColor.setChecked(colorEnabled)
self.mUi.colorButton.setColor(color)
self.mUi.spacing.setValue(spacing)
self.mUi.margin.setValue(margin)
self.mUi.browseButton.clicked.connect(self.browse)
self.mUi.name.textEdited.connect(self.nameEdited)
self.mUi.name.textChanged.connect(self.updateOkButton)
self.mUi.image.textChanged.connect(self.updateOkButton)
self.mUi.tilesetType.currentIndexChanged.connect(self.tilesetTypeChanged)
# Set the image and name fields if the given path is a file
fileInfo = QFileInfo(path)
if (fileInfo.isFile()):
self.mUi.image.setText(path)
self.mUi.name.setText(fileInfo.completeBaseName())
self.mUi.imageGroupBox.setVisible(tilesetType == 0)
self.updateOkButton()