本文整理汇总了Python中PySide.QtCore.QFile.errorString方法的典型用法代码示例。如果您正苦于以下问题:Python QFile.errorString方法的具体用法?Python QFile.errorString怎么用?Python QFile.errorString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QFile
的用法示例。
在下文中一共展示了QFile.errorString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testPhrase
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import errorString [as 别名]
def testPhrase(self):
#Test loading of quote.txt resource
f = open(adjust_filename('quoteEnUS.txt', __file__), "r")
orig = f.read()
f.close()
f = QFile(':/quote.txt')
f.open(QIODevice.ReadOnly) #|QIODevice.Text)
print("Error:", f.errorString())
copy = f.readAll()
f.close()
self.assertEqual(orig, copy)
示例2: OnSaveFilePath
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import errorString [as 别名]
def OnSaveFilePath(self, filePath):
""""""
file = QFile(filePath)
if not file.open(QFile.WriteOnly | QFile.Text):
QMessageBox.warning(self, self.tr('Warning'),
self.tr('Cannot write file') + ' %s:\n%s.' % (filePath, file.errorString()))
return False
outf = QTextStream(file)
QApplication.setOverrideCursor(Qt.WaitCursor)
outf << self.toPlainText()
QApplication.restoreOverrideCursor()
self.DoSetCurrentFilePath(filePath)
# Clear the Modified Flag.
self.document().setModified(False)
self.setWindowModified(False)
self.setWindowTitle('%s[*]' % self.fileName)
return True
示例3: webLoadFinished
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import errorString [as 别名]
def webLoadFinished(self, loaded):
print("We loaded a web page")
infile = QFile(self)
infile.setFileName("ui/resources/jquery-1.9.1.js")
if not infile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
print("Error opening file: " + infile.errorString())
stream = QtCore.QTextStream(infile)
self.jQuery = stream.readAll()
infile.close()
print("We loaded jQuery")
self._web_view.page().mainFrame().evaluateJavaScript(self.jQuery)
print("We evaluated jQuery")
self._web_view.page().mainFrame().evaluateJavaScript("$( 'div.header' ).css( '-webkit-transition', '-webkit-transform 2s'); $( 'div.header' ).css('-webkit-transform', 'rotate(360deg)')")
print("Ran some simple jQuery")
示例4: MainWindow
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import errorString [as 别名]
#.........这里部分代码省略.........
http = QHttp(self)
http.requestFinished.connect(self.httpRequestFinished)
http.dataReadProgress.connect(self.updateProgressBar)
http.responseHeaderReceived.connect(self.readResponseHeader)
self.http = http
self.ex_button = ex_button
return hlayout
def readResponseHeader(self, response_header):
# Check for genuine error conditions.
if response_header.statusCode() not in (200, 300, 301, 302, 303, 307):
self.show_error('Download failed: {}.'.format(response_header.reasonPhrase()))
self.httpRequestAborted = True
self.http.abort()
self.enable_ui_after_error()
def httpRequestFinished(self, requestId, error):
if requestId != self.httpGetId:
return
if self.httpRequestAborted:
if self.outFile is not None:
self.outFile.close()
self.outFile.remove()
self.outFile = None
return
self.outFile.close()
if error:
self.outFile.remove()
self.show_error('Download failed: {}.'.format(self.http.errorString()))
self.enable_ui_after_error()
self.continueDownloadingOrExtract()
def continueDownloadingOrExtract(self):
if self.files_to_download:
self.progress_bar.setVisible(True)
self.cancel_button.setEnabled(True)
self.disableUIWhileWorking()
self.download_file_with_error_handling()
else:
self.progress_text = 'Done.'
self.cancel_button.setEnabled(False)
self.progress_bar.setVisible(False)
self.extractFilesInBackground()
@property
def progress_text(self):
return self.progress_label.text()
@progress_text.setter
def progress_text(self, value):
self.progress_label.setText(str(value))
def runInBackground(self, method_name, callback):
self.thread = BackgroundThread(self, method_name)
self.thread.finished.connect(callback)
self.thread.start()
示例5: loadFile
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import errorString [as 别名]
def loadFile(self, fileName):
"""
TOWRITE
:param `fileName`: TOWRITE
:type `fileName`: QString
:rtype: bool
"""
qDebug("MdiWindow loadFile()")
tmpColor = self.getCurrentColor() # QRgb
file = QFile(fileName)
if not file.open(QFile.ReadOnly | QFile.Text):
QMessageBox.warning(
self,
self.tr("Error reading file"),
self.tr("Cannot read file %s:\n%s." % (fileName, file.errorString()))
)
return False
QApplication.setOverrideCursor(Qt.WaitCursor)
ext = self.fileExtension(fileName) # QString
qDebug("ext: %s" % qPrintable(ext))
# Read
p = embPattern_create() # EmbPattern*
if not p:
print("Could not allocate memory for embroidery pattern\n")
exit(1)
readSuccessful = 0 # int
## QString readError
reader = embReaderWriter_getByFileName(qPrintable(fileName)) # EmbReaderWriter*
if not reader:
readSuccessful = 0
readError = "Unsupported read file type: " + fileName
qDebug("Unsupported read file type: %s\n" % qPrintable(fileName))
else:
readSuccessful = reader.reader(p, qPrintable(fileName))
if not readSuccessful:
readError = "Reading file was unsuccessful: " + fileName
qDebug("Reading file was unsuccessful: %s\n" % qPrintable(fileName))
## free(reader) #TODO/REMOVE# not needed in python
if not readSuccessful:
QMessageBox.warning(self, self.tr("Error reading pattern"), self.tr(qPrintable(readError)))
if readSuccessful:
embPattern_moveStitchListToPolylines(p) # TODO: Test more
stitchCount = embStitchList_count(p.stitchList) # int
path = QPainterPath()
if p.circleObjList:
curCircleObj = p.circleObjList # EmbCircleObjectList*
while curCircleObj:
c = curCircleObj.circleObj.circle # EmbCircle
thisColor = curCircleObj.circleObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
# NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
self.mainWin.nativeAddCircle(embCircle_centerX(c), embCircle_centerY(c), embCircle_radius(c), False, OBJ_RUBBER_OFF) # TODO: fill
curCircleObj = curCircleObj.next
if p.ellipseObjList:
curEllipseObj = p.ellipseObjList # EmbEllipseObjectList*
while curEllipseObj:
e = curEllipseObj.ellipseObj.ellipse # EmbEllipse
thisColor = curEllipseObj.ellipseObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
# NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
self.mainWin.nativeAddEllipse(embEllipse_centerX(e), embEllipse_centerY(e), embEllipse_width(e), embEllipse_height(e), 0, False, OBJ_RUBBER_OFF) # TODO: rotation and fill
curEllipseObj = curEllipseObj.next
if p.lineObjList:
curLineObj = p.lineObjList # EmbLineObjectList*
while curLineObj:
li = curLineObj.lineObj.line # EmbLine
thisColor = curLineObj.lineObj.color # EmbColor
self.setCurrentColor(qRgb(thisColor.r, thisColor.g, thisColor.b))
# NOTE: With natives, the Y+ is up and libembroidery Y+ is up, so inverting the Y is NOT needed.
self.mainWin.nativeAddLine(embLine_x1(li), embLine_y1(li), embLine_x2(li), embLine_y2(li), 0, OBJ_RUBBER_OFF) # TODO: rotation
curLineObj = curLineObj.next
if p.pathObjList:
# TODO: This is unfinished. It needs more work
curPathObjList = p.pathObjList # EmbPathObjectList*
while curPathObjList:
pathPath = QPainterPath()
curPointList = curPathObjList.pathObj.pointList # EmbPointList*
thisColor = curPathObjList.pathObj.color # EmbColor
if curPointList:
pp = curPointList.point # EmbPoint
pathPath.moveTo(embPoint_x(pp), -embPoint_y(pp)) # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
curPointList = curPointList.next
while curPointList:
pp = curPointList.point # EmbPoint
pathPath.lineTo(embPoint_x(pp), -embPoint_y(pp)) # NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
curPointList = curPointList.next
#.........这里部分代码省略.........