本文整理汇总了Python中PyQt4.QtCore.QTextStream.seek方法的典型用法代码示例。如果您正苦于以下问题:Python QTextStream.seek方法的具体用法?Python QTextStream.seek怎么用?Python QTextStream.seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTextStream
的用法示例。
在下文中一共展示了QTextStream.seek方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LogsReadThread
# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import seek [as 别名]
class LogsReadThread(QThread):
MAX_INITIAL_SIZE = 2*1024*1024 # 2Mb
def __init__(self, parent):
QThread.__init__(self, parent)
self.fCloseNow = False
self.fPurgeLogs = False
self.fRealParent = parent
# -------------------------------------------------------------
# Take some values from Logs Window
self.LOG_FILE_JACK = LogsW.LOG_FILE_JACK
self.LOG_FILE_A2J = LogsW.LOG_FILE_A2J
self.LOG_FILE_LASH = LogsW.LOG_FILE_LASH
self.LOG_FILE_LADISH = LogsW.LOG_FILE_LADISH
# -------------------------------------------------------------
# Init logs
if self.LOG_FILE_JACK is not None:
self.fLogFileJACK = QFile(self.LOG_FILE_JACK)
self.fLogFileJACK.open(QIODevice.ReadOnly)
self.fLogStreamJACK = QTextStream(self.fLogFileJACK)
self.fLogStreamJACK.setCodec("UTF-8")
if self.fLogFileJACK.size() > self.MAX_INITIAL_SIZE:
self.fLogStreamJACK.seek(self.fLogFileJACK.size() - self.MAX_INITIAL_SIZE)
if self.LOG_FILE_A2J is not None:
self.fLogFileA2J = QFile(self.LOG_FILE_A2J)
self.fLogFileA2J.open(QIODevice.ReadOnly)
self.fLogStreamA2J = QTextStream(self.fLogFileA2J)
self.fLogStreamA2J.setCodec("UTF-8")
if self.fLogFileA2J.size() > self.MAX_INITIAL_SIZE:
self.fLogStreamA2J.seek(self.fLogFileA2J.size() - self.MAX_INITIAL_SIZE)
if self.LOG_FILE_LASH is not None:
self.fLogFileLASH = QFile(self.LOG_FILE_LASH)
self.fLogFileLASH.open(QIODevice.ReadOnly)
self.fLogStreamLASH = QTextStream(self.fLogFileLASH)
self.fLogStreamLASH.setCodec("UTF-8")
if self.fLogFileLASH.size() > self.MAX_INITIAL_SIZE:
self.fLogStreamLASH.seek(self.fLogFileLASH.size() - self.MAX_INITIAL_SIZE)
if self.LOG_FILE_LADISH is not None:
self.fLogFileLADISH = QFile(self.LOG_FILE_LADISH)
self.fLogFileLADISH.open(QIODevice.ReadOnly)
self.fLogStreamLADISH = QTextStream(self.fLogFileLADISH)
self.fLogStreamLADISH.setCodec("UTF-8")
if self.fLogFileLADISH.size() > self.MAX_INITIAL_SIZE:
self.fLogStreamLADISH.seek(self.fLogFileLADISH.size() - self.MAX_INITIAL_SIZE)
def closeNow(self):
self.fCloseNow = True
def purgeLogs(self):
self.fPurgeLogs = True
def run(self):
# -------------------------------------------------------------
# Read logs and set text in main thread
while not self.fCloseNow:
if self.fPurgeLogs:
if self.LOG_FILE_JACK:
self.fLogStreamJACK.flush()
self.fLogFileJACK.close()
self.fLogFileJACK.open(QIODevice.WriteOnly)
self.fLogFileJACK.close()
self.fLogFileJACK.open(QIODevice.ReadOnly)
if self.LOG_FILE_A2J:
self.fLogStreamA2J.flush()
self.fLogFileA2J.close()
self.fLogFileA2J.open(QIODevice.WriteOnly)
self.fLogFileA2J.close()
self.fLogFileA2J.open(QIODevice.ReadOnly)
if self.LOG_FILE_LASH:
self.fLogStreamLASH.flush()
self.fLogFileLASH.close()
self.fLogFileLASH.open(QIODevice.WriteOnly)
self.fLogFileLASH.close()
self.fLogFileLASH.open(QIODevice.ReadOnly)
if self.LOG_FILE_LADISH:
self.fLogStreamLADISH.flush()
self.fLogFileLADISH.close()
self.fLogFileLADISH.open(QIODevice.WriteOnly)
self.fLogFileLADISH.close()
self.fLogFileLADISH.open(QIODevice.ReadOnly)
self.fPurgeLogs = False
else:
#.........这里部分代码省略.........