本文整理汇总了Python中PySide.QtCore.QThread.msleep方法的典型用法代码示例。如果您正苦于以下问题:Python QThread.msleep方法的具体用法?Python QThread.msleep怎么用?Python QThread.msleep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QThread
的用法示例。
在下文中一共展示了QThread.msleep方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from PySide.QtCore import QThread [as 别名]
# 或者: from PySide.QtCore.QThread import msleep [as 别名]
def reset (self):
self.serial.setDTR (False)
self.serial.setRTS (False)
QThread.msleep (250)
self.serial.setDTR (True)
self.serial.setRTS (True)
QThread.msleep (50)
示例2: wait_for
# 需要导入模块: from PySide.QtCore import QThread [as 别名]
# 或者: from PySide.QtCore.QThread import msleep [as 别名]
def wait_for(cond, to):
"""
Wait for the condition function to return True until the timeout is met.
The timeout is broken into pieces to make sure the application can continue
processing without blocking functionality
:param cond: A function that returns a boolean
:param to: Timeout in seconds
:return: The result of the condition function
"""
watchdog = 0
msecs = (to / 8.) * 1000
while cond() is False and watchdog < 8:
QThread.msleep(msecs)
watchdog += 1
return cond()
示例3: open
# 需要导入模块: from PySide.QtCore import QThread [as 别名]
# 或者: from PySide.QtCore.QThread import msleep [as 别名]
def open (self, port, baudrate = 115200):
try:
self.serial.port = port
self.serial.baudrate = baudrate
self.serial.parity = serial.PARITY_NONE
self.serial.stopbits = serial.STOPBITS_ONE
self.serial.datasize = serial.EIGHTBITS
self.serial.timeout = self.timeout
self.serial.open ()
self.reset ()
for _i in xrange (10):
self.serial.write (const.CMD_STK_GET_SYNC + const.SYNC_CRC_EOP)
self.serial.flushInput ()
QThread.msleep (10)
self.waiting = True
while self.waiting:
self.serial.flushInput ()
self.serial.write (const.CMD_STK_GET_SYNC + const.SYNC_CRC_EOP)
QThread.msleep (random.randrange (500, 1000))
QApplication.processEvents ()
if self.serial.inWaiting () < 2:
continue
if self.readBytes (2) == const.RESP_STK_INSYNC + const.RESP_STK_OK:
break
self.changed.emit (_('Connected'))
self.progressUpdated.emit (0)
return True
except Exception as e:
traceback.print_exc ()
try:
self.serial.close ()
except:
pass
self.setError (e)
return False
示例4: execute
# 需要导入模块: from PySide.QtCore import QThread [as 别名]
# 或者: from PySide.QtCore.QThread import msleep [as 别名]
def execute (self, cmd, resLength = 0):
#print 'SENT: (%02x):' % len (cmd + const.SYNC_CRC_EOP), dump (cmd + const.SYNC_CRC_EOP)
self.serial.write (cmd)
self.serial.write (const.SYNC_CRC_EOP)
QThread.msleep (50)
return self.sync (resLength)