本文整理汇总了Python中PyQt5.QtCore.QTime.restart方法的典型用法代码示例。如果您正苦于以下问题:Python QTime.restart方法的具体用法?Python QTime.restart怎么用?Python QTime.restart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QTime
的用法示例。
在下文中一共展示了QTime.restart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: artisticSleep
# 需要导入模块: from PyQt5.QtCore import QTime [as 别名]
# 或者: from PyQt5.QtCore.QTime import restart [as 别名]
def artisticSleep(sleepTime):
time = QTime()
time.restart()
while time.elapsed() < sleepTime:
QApplication.processEvents(QEventLoop.AllEvents, 50)
示例2: MainWindow
# 需要导入模块: from PyQt5.QtCore import QTime [as 别名]
# 或者: from PyQt5.QtCore.QTime import restart [as 别名]
class MainWindow(QGraphicsView):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.updateTimer = QTimer(self)
self.demoStartTime = QTime()
self.fpsTime = QTime()
self.background = QPixmap()
self.scene = None
self.mainSceneRoot = None
self.frameTimeList = []
self.fpsHistory = []
self.currentFps = Colors.fps
self.fpsMedian = -1
self.fpsLabel = None
self.pausedLabel = None
self.doneAdapt = False
self.useTimer = False
self.updateTimer.setSingleShot(True)
self.companyLogo = None
self.qtLogo = None
self.setupWidget()
self.setupScene()
self.setupSceneItems()
self.drawBackgroundToPixmap()
def setupWidget(self):
desktop = QApplication.desktop()
screenRect = desktop.screenGeometry(desktop.primaryScreen())
windowRect = QRect(0, 0, 800, 600)
if screenRect.width() < 800:
windowRect.setWidth(screenRect.width())
if screenRect.height() < 600:
windowRect.setHeight(screenRect.height())
windowRect.moveCenter(screenRect.center())
self.setGeometry(windowRect)
self.setMinimumSize(80, 60)
self.setWindowTitle("PyQt Examples")
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.setFrameStyle(QFrame.NoFrame)
self.setRenderingSystem()
self.updateTimer.timeout.connect(self.tick)
def setRenderingSystem(self):
self.setCacheMode(QGraphicsView.CacheBackground)
self.setViewport(QWidget())
def start(self):
self.switchTimerOnOff(True)
self.demoStartTime.restart()
MenuManager.instance().itemSelected(MenuManager.ROOT,
Colors.rootMenuName)
Colors.debug("- starting demo")
def enableMask(self, enable):
if not enable or Colors.noWindowMask:
self.clearMask()
else:
region = QPolygon([
# North side.
0, 0,
800, 0,
# East side.
# 800, 70,
# 790, 90,
# 790, 480,
# 800, 500,
800, 600,
# South side.
700, 600,
670, 590,
130, 590,
100, 600,
0, 600,
# West side.
# 0, 550,
# 10, 530,
# 10, 520,
# 0, 520,
0, 0])
self.setMask(QRegion(region))
def setupScene(self):
self.scene = QGraphicsScene(self)
self.scene.setSceneRect(0, 0, 800, 600)
self.setScene(self.scene)
self.scene.setItemIndexMethod(QGraphicsScene.NoIndex)
def switchTimerOnOff(self, on):
ticker = MenuManager.instance().ticker
if ticker and ticker.scene():
#.........这里部分代码省略.........
示例3: StatusBar
# 需要导入模块: from PyQt5.QtCore import QTime [as 别名]
# 或者: from PyQt5.QtCore.QTime import restart [as 别名]
#.........这里部分代码省略.........
self._stack.setCurrentWidget(self.prompt)
self.show()
def _hide_prompt_widget(self):
"""Show temporary text instead of prompt widget."""
self._set_prompt_active(False)
self._previous_widget = PreviousWidget.none
log.statusbar.debug("Hiding prompt widget, queue: {}".format(
self._text_queue))
if self._timer_was_active:
# Restart the text pop timer if it was active before hiding.
self._pop_text()
self._text_pop_timer.start()
self._timer_was_active = False
self._stack.setCurrentWidget(self.txt)
self.maybe_hide()
def _disp_text(self, text, severity, immediately=False):
"""Inner logic for disp_error and disp_temp_text.
Args:
text: The message to display.
severity: The severity of the messages.
immediately: If set, message gets displayed immediately instead of
queued.
"""
log.statusbar.debug("Displaying text: {} (severity={})".format(
text, severity))
mindelta = config.get('ui', 'message-timeout')
if self._stopwatch.isNull():
delta = None
self._stopwatch.start()
else:
delta = self._stopwatch.restart()
log.statusbar.debug("queue: {} / delta: {}".format(
self._text_queue, delta))
if not self._text_queue and (delta is None or delta > mindelta):
# If the queue is empty and we didn't print messages for long
# enough, we can take the short route and display the message
# immediately. We then start the pop_timer only to restore the
# normal state in 2 seconds.
log.statusbar.debug("Displaying immediately")
self._set_severity(severity)
self.show()
self.txt.set_text(self.txt.Text.temp, text)
self._text_pop_timer.start()
elif self._text_queue and self._text_queue[-1] == (severity, text):
# If we get the same message multiple times in a row and we're
# still displaying it *anyways* we ignore the new one
log.statusbar.debug("ignoring")
elif immediately:
# This message is a reaction to a keypress and should be displayed
# immediately, temporarily interrupting the message queue.
# We display this immediately and restart the timer.to clear it and
# display the rest of the queue later.
log.statusbar.debug("Moving to beginning of queue")
self._set_severity(severity)
self.show()
self.txt.set_text(self.txt.Text.temp, text)
self._text_pop_timer.start()
else:
# There are still some messages to be displayed, so we queue this
# up.
log.statusbar.debug("queueing")
self._text_queue.append((severity, text))
self._text_pop_timer.start()
示例4: Connection
# 需要导入模块: from PyQt5.QtCore import QTime [as 别名]
# 或者: from PyQt5.QtCore.QTime import restart [as 别名]
#.........这里部分代码省略.........
"""
if self.__transferTimerId:
self.killTimer(self.__transferTimerId)
self.__transferTimerId = 0
if self.__numBytesForCurrentDataType <= 0:
self.__numBytesForCurrentDataType = \
self.__dataLengthForCurrentDataType()
if self.bytesAvailable() < self.__numBytesForCurrentDataType or \
self.__numBytesForCurrentDataType <= 0:
self.__transferTimerId = self.startTimer(TransferTimeout)
return False
return True
def __processData(self):
"""
Private method to process the received data.
"""
self.__buffer = QByteArray(
self.read(self.__numBytesForCurrentDataType))
if self.__buffer.size() != self.__numBytesForCurrentDataType:
self.abort()
return
if self.__currentDataType == Connection.PlainText:
self.newMessage.emit(
self.__username, str(self.__buffer, encoding="utf-8"))
elif self.__currentDataType == Connection.Ping:
self.write("{0}{1}1{1}p".format(
Connection.ProtocolPong, SeparatorToken))
elif self.__currentDataType == Connection.Pong:
self.__pongTime.restart()
elif self.__currentDataType == Connection.GetParticipants:
self.getParticipants.emit()
elif self.__currentDataType == Connection.Participants:
msg = str(self.__buffer, encoding="utf-8")
if msg == "<empty>":
participantsList = []
else:
participantsList = msg.split(SeparatorToken)
self.participants.emit(participantsList[:])
elif self.__currentDataType == Connection.Editor:
hash, fn, msg = \
str(self.__buffer, encoding="utf-8").split(SeparatorToken)
self.editorCommand.emit(hash, fn, msg)
self.__currentDataType = Connection.Undefined
self.__numBytesForCurrentDataType = 0
self.__buffer.clear()
def sendGetParticipants(self):
"""
Public method to request a list of participants.
"""
self.write(
"{0}{1}1{1}l".format(
Connection.ProtocolGetParticipants, SeparatorToken)
)
def sendParticipants(self, participants):
"""
Public method to send the list of participants.
@param participants list of participants (list of strings of
示例5: MainWindow
# 需要导入模块: from PyQt5.QtCore import QTime [as 别名]
# 或者: from PyQt5.QtCore.QTime import restart [as 别名]
#.........这里部分代码省略.........
self.arith.mode=self.cmbMode.currentIndex()
else:
if self.arith.mode>=len(self.arith.modeTexts[self.arith.diffiLevel]):
self.arith.mode=0
self.cmbMode.setCurrentIndex(self.arith.mode)
return
def on_cmbDifficulty_currentIndexChanged(self):
if self.arith:
self.arith.diffiLevel=self.cmbDifficulty.currentIndex()
if self.modeModel:
self.modeModel.setStringList(self.arith.modeTexts[self.arith.diffiLevel])
return
@pyqtSlot()
def on_tableTestPaper_itemChanged(self):
self.caseIsOpen=True
return
@pyqtSlot()
def on_btnNew_clicked(self):
"""
Slot documentation goes here.
"""
self.arith.new()
self.resetWidgets()
return
def resetWidgets(self):
self.newTestTable()
self.updateWindow()
self.caseIsOpen=True
if self.arith.timerOn:
# self.timer.start()
self.qtime.restart()
return
def newTestTable(self):
self.tableTestpaper.clear()
ncolumn=3*self.arith.nDataColumn
self.tableTestpaper.setColumnCount(ncolumn)
nTest=self.arith.getnTest()
nrow=ceil(nTest/self.arith.nDataColumn)
self.tableTestpaper.setRowCount(nrow)
self.tableTestpaper.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
headerLabels=[]
for i in range(0,self.arith.nDataColumn):
labels=['Expression', 'Answer','Y/N']
headerLabels+=labels
self.tableTestpaper.setHorizontalHeaderLabels(headerLabels)
self.tableTestpaper.resizeColumnsToContents()
self.tableTestpaper.horizontalHeader().setStretchLastSection(True)
self.tableTestpaper.horizontalHeader().resizeSections(QHeaderView.Stretch)
for k in range(0,3,2):
icol=0
for j in range(0,self.arith.nDataColumn):
irow=0
for i in range(j,nTest,int(ncolumn/3)):
item=QTableWidgetItem()
flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled
item.setFlags(flags)
self.tableTestpaper.setItem(irow,icol+k,item)
irow+=1
icol+=3
k=1
icol=0
示例6: StatusBar
# 需要导入模块: from PyQt5.QtCore import QTime [as 别名]
# 或者: from PyQt5.QtCore.QTime import restart [as 别名]
#.........这里部分代码省略.........
self._timer_was_active = True
self._text_pop_timer.stop()
self._stack.setCurrentWidget(self.prompt)
def _hide_prompt_widget(self):
"""Show temporary text instead of prompt widget."""
self._set_prompt_active(False)
self._previous_widget = PreviousWidget.none
log.statusbar.debug("Hiding prompt widget, queue: {}".format(
self._text_queue))
if self._timer_was_active:
# Restart the text pop timer if it was active before hiding.
self._pop_text()
self._text_pop_timer.start()
self._timer_was_active = False
self._stack.setCurrentWidget(self.txt)
def _disp_text(self, text, error, immediately=False):
"""Inner logic for disp_error and disp_temp_text.
Args:
text: The message to display.
error: Whether it's an error message (True) or normal text (False)
immediately: If set, message gets displayed immediately instead of
queued.
"""
log.statusbar.debug("Displaying text: {} (error={})".format(
text, error))
mindelta = config.get('ui', 'message-timeout')
if self._stopwatch.isNull():
delta = None
self._stopwatch.start()
else:
delta = self._stopwatch.restart()
log.statusbar.debug("queue: {} / delta: {}".format(
self._text_queue, delta))
if not self._text_queue and (delta is None or delta > mindelta):
# If the queue is empty and we didn't print messages for long
# enough, we can take the short route and display the message
# immediately. We then start the pop_timer only to restore the
# normal state in 2 seconds.
log.statusbar.debug("Displaying immediately")
self._set_error(error)
self.txt.set_text(self.txt.Text.temp, text)
self._text_pop_timer.start()
elif self._text_queue and self._text_queue[-1] == (error, text):
# If we get the same message multiple times in a row and we're
# still displaying it *anyways* we ignore the new one
log.statusbar.debug("ignoring")
elif immediately:
# This message is a reaction to a keypress and should be displayed
# immediately, temporarily interrupting the message queue.
# We display this immediately and restart the timer.to clear it and
# display the rest of the queue later.
log.statusbar.debug("Moving to beginning of queue")
self._set_error(error)
self.txt.set_text(self.txt.Text.temp, text)
self._text_pop_timer.start()
else:
# There are still some messages to be displayed, so we queue this
# up.
log.statusbar.debug("queueing")
self._text_queue.append((error, text))
self._text_pop_timer.start()
@pyqtSlot(str, bool)