本文整理汇总了Python中PySide.QtCore.QFile.readLine方法的典型用法代码示例。如果您正苦于以下问题:Python QFile.readLine方法的具体用法?Python QFile.readLine怎么用?Python QFile.readLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QFile
的用法示例。
在下文中一共展示了QFile.readLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LogFilePositionSource
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readLine [as 别名]
class LogFilePositionSource(QGeoPositionInfoSource):
def __init__(self, parent):
QGeoPositionInfoSource.__init__(self, parent)
self.logFile = QFile(self)
self.timer = QTimer(self)
self.timer.timeout.connect(self.readNextPosition)
self.logFile.setFileName(translate_filename('simplelog.txt'))
assert self.logFile.open(QIODevice.ReadOnly)
self.lastPosition = QGeoPositionInfo()
def lastKnownPosition(self, fromSatellitePositioningMethodsOnly):
return self.lastPosition
def minimumUpdateInterval(self):
return 100
def startUpdates(self):
interval = self.updateInterval()
if interval < self.minimumUpdateInterval():
interval = self.minimumUpdateInterval()
self.timer.start(interval)
def stopUpdates(self):
self.timer.stop()
def requestUpdate(self, timeout):
# For simplicity, ignore timeout - assume that if data is not available
# now, no data will be added to the file later
if (self.logFile.canReadLine()):
self.readNextPosition()
else:
self.updateTimeout.emit()
def readNextPosition(self):
line = self.logFile.readLine().trimmed()
if not line.isEmpty():
data = line.split(' ')
hasLatitude = True
hasLongitude = True
timestamp = QDateTime.fromString(str(data[0]), Qt.ISODate)
latitude = float(data[1])
longitude = float(data[2])
if timestamp.isValid():
coordinate = QGeoCoordinate(latitude, longitude)
info = QGeoPositionInfo(coordinate, timestamp)
if info.isValid():
self.lastPosition = info
# Currently segfaulting. See Bug 657
# http://bugs.openbossa.org/show_bug.cgi?id=657
self.positionUpdated.emit(info)
示例2: testAlias
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readLine [as 别名]
def testAlias(self):
handle = QFile(":jack")
handle.open(QFile.ReadOnly)
original = open(os.path.join(self.testdir, "shining.txt"), "r")
self.assertEqual(handle.readLine(), original.readline())
示例3: testHuge
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readLine [as 别名]
def testHuge(self):
handle = QFile(":manychars.txt")
handle.open(QFile.ReadOnly)
original = open(os.path.join(self.testdir, "manychars.txt"), "r")
self.assertEqual(handle.readLine(), original.readline())
示例4: testSimple
# 需要导入模块: from PySide.QtCore import QFile [as 别名]
# 或者: from PySide.QtCore.QFile import readLine [as 别名]
def testSimple(self):
handle = QFile(":words.txt")
handle.open(QFile.ReadOnly)
original = open(os.path.join(self.testdir, "words.txt"), "r")
self.assertEqual(handle.readLine(), original.readline())