本文整理汇总了Python中PySide.QtCore.QTimer.interval方法的典型用法代码示例。如果您正苦于以下问题:Python QTimer.interval方法的具体用法?Python QTimer.interval怎么用?Python QTimer.interval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QTimer
的用法示例。
在下文中一共展示了QTimer.interval方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Quiz
# 需要导入模块: from PySide.QtCore import QTimer [as 别名]
# 或者: from PySide.QtCore.QTimer import interval [as 别名]
#.........这里部分代码省略.........
### timers ###
self.nextQuizTimer = QTimer()
self.nextQuizTimer.setSingleShot(True)
self.nextQuizTimer.timeout.connect(self.showQuiz)
self.countdownTimer = QTimer()
self.countdownTimer.setSingleShot(True)
self.countdownTimer.timeout.connect(self.timeIsOut)
self.trayUpdater = None
#self.trayUpdater = RepeatTimer(1.0, self.updateTrayTooltip, self.options.getRepetitionInterval() * 60)
self.remaining = 0
"""Start!"""
if self.options.isQuizStartingAtLaunch():
self.waitUntilNextTimeslot()
self.trayIcon.setToolTip('Quiz has started automatically!')
self.pauseAction.setText('&Pause')
self.trayIcon.showMessage('Loading complete! (took ~'+ str(self.loadingTime.seconds) + ' seconds) Quiz underway.',
'Lo! Quiz already in progress!' + self.loadingStatus, QSystemTrayIcon.MessageIcon.Warning, 10000)
else:
self.trayIcon.setToolTip('Quiz is not initiated!')
self.trayIcon.showMessage('Loading complete! (took ~' + str(self.loadingTime.seconds) + ' seconds) Standing by.',
'Quiz has not started yet! If you wish, you could start it manually or enable autostart by default.' + self.loadingStatus,
QSystemTrayIcon.MessageIcon.Information, 10000 )
self.setWindowIcon(QIcon(PATH_TO_RES + ICONS + 'suzu.png'))
"""Test calls here:"""
### ... ###
#self.connect(self.hooker, SIGNAL('noQdict'), self.noQdict)
self.gem = self.saveGeometry()
def startUpdatingTrayTooltip(self):
self.remaining = self.nextQuizTimer.interval()
if self.trayUpdater is not None and self.trayUpdater.isAlive():
self.trayUpdater.cancel()
self.trayUpdater = RepeatTimer(1.0, self.updateTrayTooltip, self.options.getRepetitionInterval() * 60)
self.trayUpdater.start()
def updateTrayTooltip(self):
self.remaining -= UPDATE_FREQ
self.trayIcon.setToolTip('Next quiz in ' + (str(self.remaining/UPDATE_FREQ) + ' seconds'))
# def noQdict(self):
# self.showSessionMessage('Nope, cannot show quick dictionary during actual quiz.')
####################################
# Initialization procedures #
####################################
def initializeResources(self):
"""Initialize Options"""
# self.options = Options()
self.loadingStatus = u''
self.qload = QuickLoad(self.options)
if self.options.isLoadingOnStart():
self.qload.exec_()
"""Pre-initialization"""
self.animationTimer = ()
self.progressTimer = ()
self.grid_layout =()
示例2: NanoKontrol2InputHandler
# 需要导入模块: from PySide.QtCore import QTimer [as 别名]
# 或者: from PySide.QtCore.QTimer import interval [as 别名]
#.........这里部分代码省略.........
if (self._send_port is None): return
self._send_port.send(data, 0.0)
# controller button values
PLAY_BUTTON = 0x29
STOP_BUTTON = 0x2A
BACK_BUTTON = 0x2B
FORWARD_BUTTON = 0x2C
RECORD_BUTTON = 0x2D
CYCLE_BUTTON = 0x2E
PREVIOUS_TRACK_BUTTON = 0x3A
NEXT_TRACK_BUTTON = 0x3B
SET_MARK_BUTTON = 0x3C
PREVIOUS_MARK_BUTTON = 0x3D
NEXT_MARK_BUTTON = 0x3E
# controller type masks
TRANSPORT = 0x28
MARK = 0x38
LEVEL = 0x00
PAN = 0x10
SOLO = 0x20
MUTE = 0x30
ARM = 0x40
PER_TRACK = (LEVEL, PAN, SOLO, MUTE, ARM)
# interpret messages
def handle_message(self, data, time):
# ignore all long messages
if (len(data) != 3): return
(status, controller, value) = data
# filter for control-change messages
if ((status & 0xF0) != 0xB0): return
# get the kind of control this is
kind = (controller & 0xF8)
# handle mode buttons
if (controller == self.PLAY_BUTTON):
if ((value > 64) and (self.transport)):
self.transport.play()
elif (controller == self.RECORD_BUTTON):
if ((value > 64) and (self.transport)):
self.transport.record()
elif (controller == self.CYCLE_BUTTON):
if ((value > 64) and (self.transport)):
self.transport.cycling = not self.transport.cycling
# handle action buttons
elif ((kind == self.TRANSPORT) or (kind == self.MARK)):
if (value > 64):
if (self.transport):
if (controller == self.STOP_BUTTON):
self.transport.stop()
elif (controller == self.BACK_BUTTON):
self.transport.skip_back()
self.set_holding(controller)
elif (controller == self.FORWARD_BUTTON):
self.transport.skip_forward()
self.set_holding(controller)
elif (controller == self.PREVIOUS_MARK_BUTTON):
self.transport.previous_mark()
self.set_holding(controller)
elif (controller == self.NEXT_MARK_BUTTON):
self.transport.next_mark()
self.set_holding(controller)
elif (controller == self.SET_MARK_BUTTON):
self.transport.toggle_mark()
self.set_holding(controller)
else:
self.clear_holding()
self.update_led(controller, value > 64)
# handle a button being held down
def set_holding(self, button):
self._hold_button = button
if (self._hold_timer is None):
self._hold_timer = QTimer(self)
self._hold_timer.timeout.connect(self.on_hold)
self._hold_timer.setInterval(500)
self._hold_timer.start()
def clear_holding(self):
self._hold_button = None
if (self._hold_timer is not None):
self._hold_timer.stop()
def on_hold(self):
if (self._hold_button is None):
try:
self._hold_timer.stop()
except AttributeError: pass
return
self.handle_message([ 0xBF, self._hold_button, 127 ], 0.0)
if ((self._hold_timer is not None) and
(self._hold_timer.interval() != 100)):
self._hold_timer.setInterval(100)
# send a message to update the state of a button LED
def update_led(self, button, on):
try:
old_value = self._leds[button]
except KeyError:
old_value = None
value = 0
if (on):
value = 127
if (value != old_value):
self._leds[button] = value
self.send_message([ 0xBF, button, value ])
示例3: Navigator
# 需要导入模块: from PySide.QtCore import QTimer [as 别名]
# 或者: from PySide.QtCore.QTimer import interval [as 别名]
#.........这里部分代码省略.........
else:
self.logger.error('No hay exit axis muero %s' % axis.exit_point)
inst = Jaime.getInstance()
inst.finishWork()
else:
axis.cross_counter += 1
h_ev = self.human_events[axis.id]
self.crossed_axes.insert(0,axis.id)
if len(self.crossed_axes) >= 10: self.crossed_axes.pop()
self.logger.info('Stopeo el inactivity timeout')
self.inactivity_timeout.stop()
if axis.id in self.node_collected_data:
inst.route_node.doWork(self.node_collected_data[axis.id])
h_ev.fire()
except Exception as e:
# print 'Excepcion en startSecuence %s' % e
self.logger.error(e)
def getAxis(self,axis_id):
for ax in self.axis:
if ax.id == axis_id:
return ax
return None
def secuenceFinished(self):
self.logger.info('estarteo el inactivity timeout' )
self.inactivity_timeout.start()
def inactivityTimeoutAction(self):
inst = Jaime.getInstance()
self.logger.info('inactivity timeout action fired after %s seconds' % (self.inactivity_timeout.interval()/1000))
if not len(self.crossed_axes):
return
last_axis = self.crossed_axes[0]
ax = self.getAxis(last_axis)
retry_axis_id = ax.retry_axis
retry_axis = self.getAxis(retry_axis_id)
if retry_axis:
self.logger.info('El axis %s tiene como retry axis a %s lo estarteo' % (ax.id,ax.retry_axis))
self.startSecuence(retry_axis)
def processLoadStarted(self):
inst = Jaime.getInstance()
self.logger.info('Page started load to %s' % inst.view.url().toString())
# print inst.page.mainFrame().requestedUrl()
self.inactivity_timeout.stop()
self.loading_timeout.stop()
self.loading_timeout.start()
self.logger.info('Starting loading timeout and stopping inactivity timeout')
self.last_url = inst.view.url()
def loadingTimeoutAction(self):
self.logger.warning('Loading timeout fired')
inst = Jaime.getInstance()
if (not inst.view.url().isEmpty() and re.match('http.?://',inst.view.url().toString()) ) \
and not self.page_reloads:
self.logger.info('Timeout fired, reloading last url %s' % inst.view.url().toString())
self.page_reloads += 1
示例4: Transport
# 需要导入模块: from PySide.QtCore import QTimer [as 别名]
# 或者: from PySide.QtCore.QTimer import interval [as 别名]
class Transport(observable.Object, unit.Sink):
# extra signals
recording_will_start = Signal()
recording_started = Signal()
recording_will_stop = Signal()
recording_stopped = Signal()
# regular init stuff
def __init__(self, time=0.0, duration=0.0, cycling=False, marks=(),
protocol='nanokontrol2'):
observable.Object.__init__(self)
unit.Sink.__init__(self)
# set the interval to update at
self.update_interval = 0.5
# get a bridge to the JACK transport
self._client = jackpatch.Client('jackdaw-transport')
self._client.activate()
self._transport = jackpatch.Transport(client=self._client)
# make a timer to update the transport model when the time changes
self._update_timer = QTimer(self)
self._update_timer.setInterval(self.update_interval * 1000)
self._update_timer.timeout.connect(self.update_timeout)
# set up internal state
self._recording = False
self._cycling = cycling
# store all time marks
self.marks = observable.List(marks)
self._sorting_marks = False
self.marks.add_observer(self.on_marks_change)
# the start and end times of the cycle region, which will default
# to the next and previous marks if not set externally
self._cycle_start_time = None
self.cycle_start_time = None
self._cycle_end_time = None
self.cycle_end_time = None
# store the duration, which is notional and non-constraining,
# and which is meant to be maintained by users of the transport
self._duration = duration
# store the time
self._local_time = None
self.time = time
self._last_played_to = time
self._last_display_update = 0
self._start_time = None
self._local_is_rolling = None
# the amount to change time by when the skip buttons are pressed
self.skip_delta = 1.0 # seconds
# make a port and client for transport control
self._sink_type = 'midi'
self._sink_port = jackpatch.Port(name='midi.RX', client=self._client,
flags=jackpatch.JackPortIsInput)
self._source_port = jackpatch.Port(client=self._client,
name="midi.TX",
flags=jackpatch.JackPortIsOutput)
self._input_handler = None
self._protocol = None
self.protocol = protocol
# the amount of time to allow between updates of the display
self.display_interval = 0.05 # seconds
# start updating
self._update_timer.start()
self.update()
# add methods for easy button binding
def play(self, *args):
self.playing = True
def record(self, *args):
self.recording = True
def stop(self, *args):
self.playing = False
self.recording = False
# the protocol to use to interpret MIDI input
@property
def protocol(self):
return(self._protocol)
@protocol.setter
def protocol(self, value):
if ((value != self._protocol) and (value in self.protocols)):
self._protocol = value
(name, cls) = self.protocols[value]
if (self._input_handler is not None):
self._input_handler.destroy()
self._input_handler = cls(port=self.sink_port,
response_port=self._source_port,
transport=self)
# return a map from protocols to handler classes
@property
def protocols(self):
return(collections.OrderedDict((
('realtime', ('System Realtime', SystemRealtimeInputHandler)),
('nanokontrol2', ('Korg NanoKONTROL2', NanoKontrol2InputHandler))
)))
# whether play mode is on
@property
def playing(self):
return((self.is_rolling) and (not self.recording))
@playing.setter
def playing(self, value):
value = (value == True)
if (self.playing != value):
self.recording = False
if (value):
#.........这里部分代码省略.........