本文整理汇总了Python中PyQt4.QtCore.QTime.addMSecs方法的典型用法代码示例。如果您正苦于以下问题:Python QTime.addMSecs方法的具体用法?Python QTime.addMSecs怎么用?Python QTime.addMSecs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTime
的用法示例。
在下文中一共展示了QTime.addMSecs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: changerTempsChrono
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addMSecs [as 别名]
def changerTempsChrono(self,nvTemps):
"""affichage du temps sous la forme h:mm:ss:ms dans un bouton"""
temps0 = QTime(0, 0, 0)
## On augemente la précision, on ajoute les milisecondes au lieu des secondes #####
temps = temps0.addMSecs(nvTemps*self.echelle)
###########################################################################################################
mn = str(temps.minute()).zfill(2)
s = str(temps.second()).zfill(2)
ms = str(temps.msec()).zfill(3)
chrono = str(temps.hour())+':'+mn+':'+s+':'+ms
self.tempsChrono.num = chrono
self.tempsChrono.repaint()
示例2: MainWindow
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addMSecs [as 别名]
class MainWindow(QtGui.QWidget):
def __init__(self, hours, minutes, seconds, fps):
super().__init__()
self.setWindowTitle('panictimer')
if not hours and not minutes and not seconds:
hours = 1
self.time = QTime(0,0)
self.totalseconds = 0
self.panictime = hours * 3600 + minutes * 60 + seconds
self.panic = False
self.scale = 0.8
self.mode = 0
self.fps = fps
self.timer = QTimer(self)
self.timer.setInterval(1000/self.fps)
self.timer.timeout.connect(self.update_time)
self.timer.start()
# common.set_hotkey('Escape', self, self.terminal.toggle)
self.show()
def update_time(self):
self.time = self.time.addMSecs(1000/self.fps)
self.totalseconds += 1/self.fps
if self.totalseconds >= self.panictime and not self.panic:
self.panic = True
self.update()
def paintEvent(self, event):
bgcol = QColor('#111')
if self.panic:
fgcol = QColor('#e11')
else:
fgcol = QColor('#ddd')
# Size and shit
w, h = self.width(), self.height()
minsize = min(w,h)*self.scale
arcwidth = minsize*0.1
minsize *= 0.86
marginx = (w-minsize)/2
marginy = (h-minsize)/2
# Start drawing shit
painter = QPainter(self)
painter.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing)
painter.setPen(QPen(fgcol, arcwidth, cap=Qt.FlatCap))
#font = QFont('sv basic manual')
font = QFont('bank gothic')
font.setPointSize(get_font_size(font, minsize-2*arcwidth))
smallfont = QFont(font)
smallfont.setPointSizeF(font.pointSize()/2)
painter.fillRect(QRectF(0,0,w,h), bgcol)
# Timer dial thingy
painter.setOpacity(0.05)
painter.drawArc(marginx,marginy, minsize,minsize, 0, 5760)
painter.setOpacity(1)
arclength = min(1, self.totalseconds/self.panictime) * 5760
painter.drawArc(marginx,marginy, minsize,minsize, 90*16, -arclength)
# Timer text
painter.setFont(font)
textoptions = QtGui.QTextOption(Qt.AlignCenter)
painter.drawText(QRectF(marginx, marginy, minsize, minsize),
self.get_text(0), textoptions)
painter.setFont(smallfont)
painter.setOpacity(0.5)
painter.drawText(QRectF(marginx, marginy+minsize*0.4, minsize, minsize/2),
self.get_text(1), textoptions)
#painter.setOpacity(0.15)
#painter.drawText(QRectF(marginx, marginy+minsize*0.05, minsize, minsize/2),
# self.get_text(2), textoptions)
painter.end()
def get_text(self, item):
if item == 2:
h, rest = divmod(self.panictime, 3600)
m, s = divmod(rest, 60)
return 'target:\n{:0>2}:{:0>2}:{:0>2}'.format(h,m,s)
texts = [
self.time.toString('HH:mm:ss'),
'{:.2%}'.format(self.totalseconds/self.panictime)
]
if self.mode == 0:
return texts[item]
elif self.mode == 1:
return texts[::-1][item]
elif self.mode == 2:
return [texts[0], ''][item]
elif self.mode == 3:
return [texts[1], ''][item]
def change_view_mode(self):
self.mode += 1
if self.mode > 3:
self.mode = 0
def wheelEvent(self, event):
if event.delta() > 0:
#.........这里部分代码省略.........