本文整理汇总了Python中PyQt4.QtCore.QTime类的典型用法代码示例。如果您正苦于以下问题:Python QTime类的具体用法?Python QTime怎么用?Python QTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
time = QTime()
eventLoop = QEventLoop()
self.m_bStop = False
# log.debug("Запускаем поток")
#if not self.initThread():
#return
while not self.m_bStop:
self.m_nTactCounter += 1 # Добавить обнуление при переполнении
time.start()
eventLoop.processEvents()
if not self.workThread():
self.m_bStop = True
return
workTime = time.elapsed()
if 0 <= workTime < self.m_nTact:
self.msleep(self.m_nTact - workTime)
else:
self.msleep(0)
eventLoop.processEvents()
self.exitThread()
示例2: sleep
def sleep(self, ms):
startTime = QTime.currentTime()
while True:
QApplication.processEvents(QEventLoop.AllEvents, 25)
if startTime.msecsTo(QTime.currentTime()) > ms:
break
usleep(0.005)
示例3: _import
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))
示例4: addX
def addX(self,a):
self.Xresult = []
self.Xindex = a
if self.isProcess==False:
self.dlineEdit_X.setText("X : " + str(self.df.columns[self.Xindex + 6]))
self.Xresult = np.array(self.df[self.df.columns[self.Xindex + 6]])
if self.df.columns[self.Xindex + 6] == "Date":
for tab in range(len(self.Xresult)):
tempdate=QDate.fromString(self.Xresult[tab],"yy-MM-dd")
tempdate.setYMD(tempdate.year()+100,tempdate.month(),tempdate.day())
self.Xresult[tab] =tempdate.toPyDate()
elif self.df.columns[self.Xindex + 6] == "Time":
for tab in range(len(self.Xresult)):
self.Xresult[tab] = QTime.fromString(self.Xresult[tab]).toPyTime()
#self.Xresult[tab]=np.datetime_as_string(self.Xresult[tab])
else:
pass
else:
self.dlineEdit_X.setText("X : " + str(self.ts1.columns[0]))
tempx=[]
for tab in xrange(len(self.ts1[self.ts1.columns[0]])):
#print self.ts1[self.ts1.columns[0]][0]
#print type(self.ts1[self.ts1.columns[0]][0])
(val1,val2)=str(self.ts1[self.ts1.columns[0]][tab]).split(' ',1)
tempx.append( QTime.fromString(val2).toPyTime())
self.Xresult = np.array(tempx)
示例5: _initInputUI
def _initInputUI(self, layout):
self.setWindowTitle(self._title)
messageLabel = QLabel(self._message, self)
messageLabel.setWordWrap(True)
layout.addWidget(messageLabel)
inputWidget = QWidget(self)
inputLayout = QHBoxLayout(inputWidget)
inputLayout.setContentsMargins(0, 0, 0, 0)
if type(self._initialBegin) != QTime:
initialBegin = QTime.fromString(self._initialBegin, lunch_settings.LUNCH_TIME_FORMAT_QT)
if type(self._initialEnd) != QTime:
initialEnd = QTime.fromString(self._initialEnd, lunch_settings.LUNCH_TIME_FORMAT_QT)
inputLayout.addWidget(QLabel("From", self))
self.beginEdit = QTimeEdit(self)
self.beginEdit.setDisplayFormat("HH:mm")
self.beginEdit.setTime(initialBegin)
inputLayout.addWidget(self.beginEdit)
inputLayout.addWidget(QLabel("to", self))
self.endEdit = QTimeEdit(self)
self.endEdit.setDisplayFormat("HH:mm")
self.endEdit.setTime(initialEnd)
inputLayout.addWidget(self.endEdit)
layout.addWidget(inputWidget, 0, Qt.AlignLeft)
示例6: __init__
def __init__(self, db, sql, parent=None):
self.db = db.connector
t = QTime()
t.start()
c = self.db._execute(None, unicode(sql))
self._secs = t.elapsed() / 1000.0
del t
self._affectedRows = 0
data = []
header = self.db._get_cursor_columns(c)
if header is None:
header = []
try:
if len(header) > 0:
data = self.db._fetchall(c)
self._affectedRows = c.rowcount
except DbError:
# nothing to fetch!
data = []
header = []
BaseTableModel.__init__(self, header, data, parent)
# commit before closing the cursor to make sure that the changes are stored
self.db._commit()
c.close()
del c
示例7: handleMouseMove
def handleMouseMove(self, event):
event.ignore()
if not (event.buttons() & Qt.LeftButton):
return
if event in self.d.ignoreList:
self.d.ignoreList.remove(event)
return
if self.d.state in (FlickablePrivate.Pressed, FlickablePrivate.Stop):
delta = event.pos() - self.d.pressPos
if delta.x() > self.d.threshold or delta.x() < -self.d.threshold or \
delta.y() > self.d.threshold or delta.y() < -self.d.threshold:
self.d.timeStamp = QTime.currentTime()
self.d.state = FlickablePrivate.ManualScroll
self.d.delta = QPoint(0, 0)
self.d.pressPos = QPoint(event.pos())
#event.accept()
elif self.d.state == FlickablePrivate.ManualScroll:
event.accept()
delta = event.pos() - self.d.pressPos
self.setScrollOffset(self.d.offset - delta)
if self.d.timeStamp.elapsed() > 50:
self.d.timeStamp = QTime.currentTime()
self.d.speed = delta - self.d.delta
self.d.delta = delta
print("Delta", self.d.delta)
self.emit(SIGNAL("scroll_to"), self.d.pressPos, self.d.delta)
示例8: __init__
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
uic.loadUi('mainwindow.ui', self)
self.setWindowTitle('Merlins AFM sketching tool')
self.setGeometry(500,100,1200,1000)
self.plotFrame = PlotFrame()
self.plotSplitter.addWidget(self.plotFrame)
# self.splitter.setStretch(1,1)
self.splitter.setStretchFactor(1,1)
# self.tree_splitter.set
self.show()
# Set delegate
self.tree_file.setItemDelegateForColumn(2,DoubleSpinBoxDelegate(self))
self.tree_file.setItemDelegateForColumn(4,DoubleSpinBoxDelegate(self))
self.settings = {}
self.settings['measure'] = {}
self.settings['plot'] = {}
self.settings['measure']['time'] = QTime()
self.s_time = str(QDate.currentDate().toString('yyyy-MM-dd_') + QTime.currentTime().toString('HH-mm-ss'))
self.timer = QTime.currentTime()
self.nextPosition = np.array([np.nan,np.nan])
self.sketching = False
self.outDir = 'U:/'
self.afmImageFolder = 'D:/lithography/afmImages/'
self.storeFolder = 'D:/lithography/sketches/' + self.s_time + '/'
self.sketchSubFolder = './'
print ''
print ''
self.addToolbars()
self.init_stores()
self.newstores = False
self.init_sketching()
self.init_measurement()
self.tree_settings.hide()
# # Tree view
# self.set_model = SetTreeModel(headers = ['Parameter', 'Value', 'type'], data = self.settings)
# self.tree_settings.setModel(self.set_model)
# self.tree_settings.setAlternatingRowColors(True)
# self.tree_settings.setSortingEnabled(True)
# self.tree_settings.setHeaderHidden(False)
# self.tree_settings.expandAll()
# for column in range(self.set_model.columnCount()):
# self.tree_settings.resizeColumnToContents(column)
# QtCore.QObject.connect(self.set_model, QtCore.SIGNAL('itemChanged(QModelIndex)'), self.test)
# QtCore.QObject.connect(self.tree_settings, QtCore.SIGNAL('valueChanged(QModelIndex)'), self.test)
self.log('log', 'init')
示例9: writeDataToSocket
def writeDataToSocket(self):
hour = "%02d"%(QTime.currentTime().hour())
minute = "%02d"%(QTime.currentTime().minute())
second = "%02d"%(QTime.currentTime().second())
if self.teacherIp != "":
ip = self.teacherIp
name = "client-" + self.clientuuid
data = name + "#" + hour + minute + second
self.udpSocket.writeDatagram(data, QHostAddress(ip), self.porttwo)
示例10: AutoSaver
class AutoSaver(QObject):
"""
Class implementing the auto saver.
"""
AUTOSAVE_IN = 1000 * 3
MAXWAIT = 1000 * 15
def __init__(self, parent, save):
"""
Constructor
@param parent reference to the parent object (QObject)
@param save slot to be called to perform the save operation
"""
QObject.__init__(self, parent)
if parent is None:
raise RuntimeError("AutoSaver: parent must not be None.")
self.__save = save
self.__timer = QBasicTimer()
self.__firstChange = QTime()
def changeOccurred(self):
"""
Public slot handling a change.
"""
if self.__firstChange.isNull():
self.__firstChange.start()
if self.__firstChange.elapsed() > self.MAXWAIT:
self.saveIfNeccessary()
else:
self.__timer.start(self.AUTOSAVE_IN, self)
def timerEvent(self, evt):
"""
Protected method handling timer events.
@param evt reference to the timer event (QTimerEvent)
"""
if evt.timerId() == self.__timer.timerId():
self.saveIfNeccessary()
else:
QObject.timerEvent(self, evt)
def saveIfNeccessary(self):
"""
Public method to activate the save operation.
"""
if not self.__timer.isActive():
return
self.__timer.stop()
self.__firstChange = QTime()
self.__save()
示例11: OpenAnt
class OpenAnt(QApplication):
def __init__(self):
QApplication.__init__(self, sys.argv)
# Set the default background color to a darker grey.
self.setPalette(QPalette(self.palette().button().color(), QColor(192, 192, 192)))
self.window = MainWindow()
self.window.show()
self.window.start()
self.window.setWindowTitle('OpenAnt')
# Game timer, used in the gameloop FPS calculations.
self.game_timer = QTime()
self.game_timer.start()
# Draw map, set view to ground.
self.map = Map()
Globals.view = self.map.generateMap()
self.map.spawnAnts()
# Start the main loop.
self.gameLoop()
def gameLoop(self):
TICKS_PER_SECOND = 20
SKIP_TICKS = 1000 / TICKS_PER_SECOND
MAX_FRAMESKIP = 5
next_game_tick = self.getTickCount()
Globals.game_is_running = True
while Globals.game_is_running:
loops = 0
while self.getTickCount() > next_game_tick and loops < MAX_FRAMESKIP:
self.updateGame()
next_game_tick += SKIP_TICKS
loops += 1
interpolation = float(self.getTickCount() + SKIP_TICKS - next_game_tick) / float(SKIP_TICKS)
self.updateDisplay(interpolation)
def updateDisplay(self, interpolation):
#lerp away
if not 'nolerp' in sys.argv:
if self.map.yellowAnt.moving:
self.map.yellowAnt.lerpMoveSimple(interpolation)
Globals.glwidget.updateGL()
self.processEvents() # Let Qt process its events.
def getTickCount(self):
return self.game_timer.elapsed()
def updateGame(self):
self.map.update()
示例12: __init__
def __init__(self, parent=None, testing=False, participantId=None):
# Initialize object using ui_addParticipant
super(EditParticipantDialog, self).__init__(parent)
self.ui = Ui_AddParticipantDialog()
self.ui.setupUi(self)
# Initialize class variables
self.testing = testing
if participantId is None:
QMessageBox.critical(self, 'Invalid Participant', "An invalid participant was chosen.", QMessageBox.Ok)
self.reject()
# if participantId[0] == 's':
# self.participantId = participantId[1:]
# else:
# self.participantId = participantId
self.participantId = participantId
self.participant = dbInteractionInstance.getParticipantFromId(participantId)
# Set up the contact
self.contactId = self.participant.contact
if self.contactId:
c = dbInteractionInstance.getTeacherFromId(self.contactId)
if c is not None:
self.ui.contactPersonLineEdit.setText("{0} {1}".format(c.first, c.last))
# Initialize ui with variables
self.ui.addParticipantBtn.setText("&Update Participant")
self.setWindowTitle("Edit Participant")
self.ui.firstNameLineEdit.setText(self.participant.first)
self.ui.lastNameLineEdit.setText(self.participant.last)
self.ui.addressLineEdit.setText(self.participant.address)
self.ui.cityLineEdit.setText(self.participant.city)
self.ui.postalCodeLineEdit.setText(humanPostalCodeFormat(self.participant.postal))
self.ui.homePhoneLineEdit.setText(humanPhoneNumberFormat(self.participant.home))
self.ui.cellPhoneLineEdit.setText(humanPhoneNumberFormat(self.participant.cell))
self.ui.emailLineEdit.setText(self.participant.email)
self.ui.dateOfBirthDateEdit.setDate(QDate.fromString(self.participant.dob, "yyyy-MM-dd"))
self.ui.ageLabel.setText("Age as of Jan. 1 {0}".format(QDate.currentDate().year()))
self.ui.schoolAttendingLineEdit.setText(self.participant.schoolAttending)
self.ui.parentLineEdit.setText(self.participant.parent)
self.ui.schoolGradeLineEdit.setText(self.participant.schoolGrade)
self.ui.groupNameLineEdit.setText(self.participant.groupName)
self.ui.numberParticipantsLineEdit.setText(self.participant.numberParticipants)
self.ui.schoolGradeLineEdit.setText(self.participant.schoolGrade)
self.ui.averageAgeLineEdit.setText(self.participant.averageAge)
if self.participant.earliestPerformanceTime != "":
self.ui.timeConstraintsGroupBox.setChecked(True)
self.ui.earliestPerformanceTimeTimeEdit.setTime(QTime.fromString(self.participant.earliestPerformanceTime, "h:mm A"))
self.ui.latestPerformanceTimeTimeEdit.setTime(QTime.fromString(self.participant.latestPerformanceTime, "h:mm A"))
self.ui.participantsTextEdit.setText(self.participant.participants)
# Set the age display
self.dob_changed()
# Make the buttons do things
self.connectSlots()
示例13: timeval_to_label
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")))
示例14: changerTempsChrono
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()
示例15: __new__
def __new__(cls, value):
"""
Helper. Takes a date like value and attempts to convert
it to a simple QTime type.
"""
if isinstance(value, QTime):
return value
if isinstance(value, datetime):
return QTime.__new__(value.hour, value.minute)
if isinstance(value, unicode):
return QTime.__new__(parse(value).hour, parse(value).minute)
if isinstance(value, str):
return QTime.__new__(parse(value).hour, parse(value).minute)