本文整理汇总了Python中PyQt4.QtCore.QTime.addSecs方法的典型用法代码示例。如果您正苦于以下问题:Python QTime.addSecs方法的具体用法?Python QTime.addSecs怎么用?Python QTime.addSecs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTime
的用法示例。
在下文中一共展示了QTime.addSecs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _import
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addSecs [as 别名]
def _import(self, attr_type, attr):
"""
Your attribute in self.cfg has the same name as the Qt widget controlling it
Supported attr_type:
* 'bool' for booleans
* 'string' for string, unicode... <--> QString in lineEdit
* 'time' for time in seconds <--> QTime in timeEdit
"""
value = getattr(self._cfg, attr)
control = getattr(self, attr)
if attr_type == 'bool':
if value:
check_state = Qt.Checked
else:
check_state = Qt.Unchecked
control.setChecked(check_state)
elif attr_type == 'string':
if isinstance(control, QLineEdit):
method = control.setText
elif isinstance(control, QPlainTextEdit):
method = control.setPlainText
method(value)
elif attr_type == 'time':
time = QTime(0, 0, 0, 0)
control.setTime(time.addSecs(value))
示例2: setTimeEnd
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addSecs [as 别名]
def setTimeEnd( self, timeEnd ):
"""
Sets the end time for this item. This method will only affect the
start time if the end time is set to occur before its start, in which
case it will set the start time as 60 minutes before.
Otherwise, this method will scale the duration of the event.
:param timeEnd | <QTime>
"""
timeEnd = QTime(timeEnd)
if ( timeEnd < self._timeStart ):
self._timeStart = timeEnd.addSecs(-60 * 60)
self._timeEnd = timeEnd
self.markForRebuild()
示例3: setTimeStart
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addSecs [as 别名]
def setTimeStart( self, timeStart ):
"""
Sets the start time for this item. This will automatically push the
end time to match the length for this item. So if the item starts
at 11a and ends on 1p, and the start time is changed to 12p
the end time will change to 2p. To affect the length of the
item, use either setLength, or setTimeEnd.
:param timeStart | <QDate>
"""
timeStart = QTime(timeStart)
length = self.length() # in minutes
self._timeStart = timeStart
self._timeEnd = timeStart.addSecs(length * 60)
self.markForRebuild()
示例4: __init__
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addSecs [as 别名]
def __init__( self ):
super(XCalendarItem, self).__init__()
curr_dtime = QDateTime.currentDateTime()
curr_date = curr_dtime.date()
curr_time = curr_dtime.time()
self.setFlags(self.flags() | self.ItemIsSelectable)
self.setAcceptHoverEvents(True)
# round to the nearest 15 minute segment
curr_time = QTime(curr_time.hour(),
curr_time.minute() - curr_time.minute() % 30,
0)
self._rebuildBlocked = False
self._textData = []
self._customData = {}
self._textColor = QColor('white')
self._fillColor = QColor('blue')
self._borderColor = QColor('blue')
self._highlightColor = QColor('blue')
self._title = 'No Title'
self._description = ''
self._dateStart = curr_date
self._dateEnd = curr_date
self._timeStart = curr_time
self._timeEnd = curr_time.addSecs(60 * 60)
self._allDay = True
self._rebuildRequired = False
if ( QTime(23, 0, 0) <= self._timeStart ):
self._timeEnd = QTime(23, 59, 0)
self.setColor('blue')
示例5: Sudoku
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addSecs [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:
#.........这里部分代码省略.........
示例6: rebuildDays
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import addSecs [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()
#.........这里部分代码省略.........