本文整理汇总了Python中PyQt4.QtCore.QTime.toString方法的典型用法代码示例。如果您正苦于以下问题:Python QTime.toString方法的具体用法?Python QTime.toString怎么用?Python QTime.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTime
的用法示例。
在下文中一共展示了QTime.toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: timeval_to_label
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import toString [as 别名]
def timeval_to_label(self, val):
"""
Convert the tracks play-length into a format
suitable for label widget and set
"""
trk_time = self.audio_object.totalTime() # FIXME: this is wrong n the transistion period
trk_time = QTime(0, (trk_time / 60000) % 60, (trk_time / 1000) % 60)
t_now = QTime(0, (val / 60000) % 60, (val / 1000) % 60)
self.ui.progress_lbl.setText("%s | %s" % (t_now.toString('mm:ss'),
trk_time.toString("mm:ss")))
示例2: MainWindow
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import toString [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:
#.........这里部分代码省略.........
示例3: tick
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import toString [as 别名]
def tick(self, time):
displayTime = QTime(0, (time / 60000) % 60, (time / 1000) % 60)
self.timeLcd.display(displayTime.toString('mm:ss'))
示例4: Sudoku
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import toString [as 别名]
class Sudoku(QMainWindow):
def __init__(self,dificultad,invalida,incorrecta,ayuda,partida):
"""Contructor
*Crea una instancia de Sudoku de acuerdo a las especificaciones dadas por las variables de entrada.
*Se crea e inicia el cronometro.
Parametro:
- dificultad Dificultad del juego.
- incorrecta Determina si se realizan o no las validaciones de jugadas incorrectas.
- invalida Determina si se realizan o no las validaciones de jugadas invalidas.
- ayuda Determina si se activa o no el boton ayuda."""
QMainWindow.__init__(self)
self.ui= Ui_Sudoku()
self.ui.setupUi(self)
self.dificultad=dificultad
self.invalida=invalida
self.incorrecta=incorrecta
self.ayuda=ayuda
self.partida=partida
if self.ayuda==False:
self.ui.btHelp.setEnabled(False)
else:
self.ayudas=0
self.initCronometro()
self.validador=Validador(self)
self.validador.graficador.initArregloImgFichas()
self.initArregloPistas()
self.initGui()
self.ui.pBf1.clicked.connect(self.onPbf1Clicked)
self.ui.pBf2.clicked.connect(self.onPbf2Clicked)
self.ui.pBf3.clicked.connect(self.onPbf3Clicked)
self.ui.pBf4.clicked.connect(self.onPbf4Clicked)
self.ui.pBf5.clicked.connect(self.onPbf5Clicked)
self.ui.pBf6.clicked.connect(self.onPbf6Clicked)
self.ui.pBf7.clicked.connect(self.onPbf7Clicked)
self.ui.pBf8.clicked.connect(self.onPbf8Clicked)
self.ui.pBf9.clicked.connect(self.onPbf9Clicked)
self.ui.btHelp.clicked.connect(self.onBtHelpClicked)
self.ui.actionNuevo_Juego.triggered.connect(self.onActionnuevo_juegoTriggered)
self.ui.actionGuardar.triggered.connect(self.onActionguardarTriggered)
self.ui.actionSalir.triggered.connect(self.onActionsalirTriggered)
self.MessageBox= ctypes.windll.user32.MessageBoxA
self.MB_ICONERROR = 0x00000010L #Critical Icon
self.MB_ICONEXCLAMATION= 0x00000030L #Exclamation Icon
def initCronometro(self):
"""Inicia el contador del cronometro"""
self.tiempo = QTime()
self.tiempo.setHMS(0,0,0,0)
self.timer = QTimer()
self.connect(self.timer, SIGNAL("timeout()"),self.mostrarTiempo)
self.segundos = 0
self.text = self.tiempo.toString("hh:mm:ss")
self.ui.contTiempo.display(self.text)
self.timer.start(1000)
def mostrarTiempo(self):
"""Controla el aumento de los segundos"""
self.nuevoTiempo = QTime()
self.segundos = self.segundos + 1
self.nuevoTiempo = self.tiempo.addSecs(self.segundos)
self.cronometro = self.nuevoTiempo.toString("hh:mm:ss")
self.ui.contTiempo.display(self.cronometro)
def initGui(self):
"""Inicializa la interfaz grafica del tablero
Se inicializa el tablero y luego se lo llena con el numero de fichas de acuerdo a la dificultad."""
self.Bmetodo=0
self.cajas=[]
for i in range(9):
qpushbutton=[]
for j in range(9):
qpushbutton.append(QPushButton())
self.cajas.append(qpushbutton)
for i in range(9):
for j in range(9):
self.cajas[i][j].setIcon(self.imgFichas[0])
self.cajas[i][j].setIconSize(QSize(48, 48))
self.cajas[i][j].setAccessibleName("0")
self.cajas[i][j].setStyleSheet("*{background-color:rgb(158,209,247)}")
self.ui.gLTablero.addWidget(self.cajas[i][j],i,j)
self.cajas[i][j].clicked.connect(self.onColocarFicha)
self.validador.Relacionar()
if self.dificultad!=5:
self.leerArchivoSudokuResuelto()
self.llenaTableroDificultad()
else:
self.cargarPartida()
def onColocarFicha(self):
"""Slot que se ejecuta cada vez que se presione en algun boton dentro del tablero
Determina que accion se realiza al pulsar la ficha en el tablero.
Controla que tipo de validacion se realiza."""
caja=QPushButton()
caja=self.sender()
if self.Bmetodo==0:
for i in range(9):
self.posFichas[i].setIcon(self.imgFichas[0])
self.muestraPosiblesFichas(caja)
else:
#.........这里部分代码省略.........
示例5: rebuildDays
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import toString [as 别名]
def rebuildDays( self ):
"""
Rebuilds the interface as a week display.
"""
time = QTime(0, 0, 0)
hour = True
x = 6
y = 6 + 24
w = self.width() - 12 - 25
dh = 48
indent = 58
text_data = []
vlines = []
hlines = [QLine(x, y, w, y)]
time_grids = []
for i in range(48):
if ( hour ):
hlines.append(QLine(x, y, w, y))
text_data.append((x,
y + 6,
indent - 6,
dh,
Qt.AlignRight | Qt.AlignTop,
time.toString('hap')))
else:
hlines.append(QLine(x + indent, y, w, y))
time_grids.append((time, y, dh / 2))
# move onto the next line
hour = not hour
time = time.addSecs(30 * 60)
y += dh / 2
hlines.append(QLine(x, y, w, y))
h = y
y = 6 + 24
# load the grid
vlines.append(QLine(x, y, x, h))
vlines.append(QLine(x + indent, y, x + indent, h))
vlines.append(QLine(w, y, w, h))
today = QDate.currentDate()
curr_date = self.currentDate()
# load the days
if ( self.currentMode() == XCalendarScene.Mode.Week ):
date = self.currentDate()
day_of_week = date.dayOfWeek()
if ( day_of_week == 7 ):
day_of_week = 0
min_date = date.addDays(-day_of_week)
max_date = date.addDays(6-day_of_week)
self._minimumDate = min_date
self._maximumDate = max_date
dw = (w - (x + indent)) / 7.0
vx = x + indent
date = min_date
for i in range(7):
vlines.append(QLine(vx, y, vx, h))
text_data.append((vx + 6,
6,
dw,
24,
Qt.AlignCenter,
date.toString('ddd MM/dd')))
self._dateGrid[date.toJulianDay()] = ((0, i),
QRectF(vx, y, dw, h - y))
# create the date grid for date time options
for r, data in enumerate(time_grids):
time, ty, th = data
dtime = QDateTime(date, time)
key = dtime.toTime_t()
self._dateTimeGrid[key] = ((r, i), QRectF(vx, ty, dw, th))
if ( date == curr_date ):
self._buildData['curr_date'] = QRectF(vx, y, dw, h - 29)
elif ( date == today ):
self._buildData['today'] = QRectF(vx, y, dw, h - 29)
date = date.addDays(1)
vx += dw
# load a single day
else:
date = self.currentDate()
#.........这里部分代码省略.........
示例6: on_upload_thread_information
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import toString [as 别名]
def on_upload_thread_information(self, info):
time = QTime(QTime.currentTime())
self.textBrowser.append(u"[%s] %s" % (time.toString(), info))