本文整理汇总了Python中PySide.QtCore.QTimer类的典型用法代码示例。如果您正苦于以下问题:Python QTimer类的具体用法?Python QTimer怎么用?Python QTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reverseCalculationWorker
def reverseCalculationWorker(self, seconds_before_start):
self.message.sendMessage('second_' + str(seconds_before_start))
if seconds_before_start == 0:
self.timer.start()
self.animation_timer.start()
QTimer.singleShot(1000, self.message.noMessage)
self.repaint()
示例2: error
def error(self, error):
if error == QNetworkSession.UnknownSessionError:
msgBox = QMessageBox(self.parent())
msgBox.setText('This application requires network access to function.')
msgBox.setInformativeText('Press Cancel to quit the application.')
msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel)
msgBox.setIcon(QMessageBox.Information)
msgBox.setDefaultButton(QMessageBox.Retry)
ret = msgBox.exec_()
if ret == QMessageBox.Retry:
QTimer.singleShot(0, self.session.open)
elif ret == QMessageBox.Cancel:
self.close()
elif error == QNetworkSession.SessionAbortedError:
msgBox = QMessageBox(self.parent())
msgBox.setText('Out of range of network')
msgBox.setInformativeText('Move back into range and press Retry, or press Cancel to quit the application')
msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel)
msgBox.setIcon(QMessageBox.Information)
msgBox.setDefaultButton(QMessageBox.Retry)
ret = msgBox.exec_()
if ret == QMessageBox.Retry:
QTimer.singleShot(0, self.session.open)
elif ret == QMessageBox.Cancel:
self.close()
示例3: TestTimeoutSignal
class TestTimeoutSignal(UsesQCoreApplication):
'''Test case to check if the signals are really being caught'''
def setUp(self):
#Acquire resources
UsesQCoreApplication.setUp(self)
self.watchdog = WatchDog(self)
self.timer = QTimer()
self.called = False
def tearDown(self):
#Release resources
del self.watchdog
del self.timer
del self.called
UsesQCoreApplication.tearDown(self)
def callback(self, *args):
#Default callback
self.called = True
def testTimeoutSignal(self):
#Test the QTimer timeout() signal
refCount = sys.getrefcount(self.timer)
QObject.connect(self.timer, SIGNAL('timeout()'), self.callback)
self.timer.start(4)
self.watchdog.startTimer(10)
self.app.exec_()
self.assert_(self.called)
self.assertEqual(sys.getrefcount(self.timer), refCount)
示例4: wc
def wc(stream_update=None, object_transfer=None):
"""
Connect to the woodchuck server and initialize any state.
stream_update is a function that is passed two arguments: an
account identifier and the name of the stream to update (e.g.,
'HomeTimeline').
object_transfer is a function that is passed three arguments: an
account identifier, a name of the stream and the post to transfer.
If channel_update and episode_download are None, then Woodchuck
upcalls will be disabled.
"""
global _w
if _w is not None:
return _w
_w = mywoodchuck(stream_update, object_transfer)
if not _w.available():
logging.info("Woodchuck support disabled: unable to contact Woodchuck server.")
print "Woodchuck support disabled: unable to contact Woodchuck server."
return _w
logging.info("Woodchuck appears to be available.")
if stream_update is not None:
QTimer.singleShot(10 * 1000, _w.synchronize_config)
return _w
示例5: testFontInfo
def testFontInfo(self):
w = MyWidget()
w._app = self.app
w._info = None
QTimer.singleShot(300, w.show)
self.app.exec_()
self.assert_(w._info)
示例6: __init__
def __init__(self):
self.network_manager = CustomNetworkAccessManager.getInstance()
self.axis = []
self.human_events = {}
self.node_collected_data = {}
self.last_url = None
self.current_url = QUrl()
self.current_axis_id = None
self.crossed_axis_method = None
self.crossed_axes = []
self.crossed_axes_string = ''
self.cross_axis_delay = QTimer()
self.cross_axis_delay.setSingleShot(True)
self.cross_axis_delay.timeout.connect(self.crossedAxis)
self.cross_axis_params = None
self.loading_timeout = QTimer()
self.loading_timeout.setSingleShot(True)
self.loading_timeout.setInterval(30000)
self.loading_timeout.timeout.connect(self.loadingTimeoutAction)
self.inactivity_timeout = QTimer()
self.inactivity_timeout.setSingleShot(True)
self.inactivity_timeout.setInterval(10000)
self.inactivity_timeout.timeout.connect(self.inactivityTimeoutAction)
self.page_reloads = 0
Logger.getLoggerFor(self.__class__)
示例7: WidgetFader
class WidgetFader(object):
'''
For a given widget in the UI, this fader attaches a timer
that hides that widget after a specified interval
'''
def make_active(self):
'''
shows the widget then sets the hide timer
'''
self.controls.show()
self.timer.start(self.time_out)
def make_inactive(self):
self.controls.hide()
def __init__(self, controls, time_out=1500):
'''
Constructor
'''
self.timer = QTimer()
self.timer.timeout.connect(self.make_inactive)
self.timer.setSingleShot(True)
self.time_out = time_out
self.controls = controls
self.controls.hide()
示例8: RecomenDesktopApp
class RecomenDesktopApp(TaskTrayApp):
def __init__(self, parent=None):
super(RecomenDesktopApp, self).__init__(parent)
# :: DBへのアップデートチェック
self.updateChecker = DBUpdateChecker()
self.updateChecker.start()
self.updateChecker.finished.connect(self.add_news)
# :: DBの新規更新の定期チェック
self.updateCheck_timer = QTimer()
self.updateCheck_timer.setInterval(10)
self.stack = []
@Slot()
def add_news(self, news):
print "add_news"
if not news.hasupdate:
return
for new in news.get_datas():
if new in self.get_local_db():
print "Non News late"
continue
self.add_stack(new)
print "add stack"
def add_stack(self, n):
self.stack.append(n)
def get_local_db(self):
return [2,3,4,5]
示例9: __init__
def __init__(self, process, input_queue, output_queue):
super(MainWidget, self).__init__()
self.done = False
layout = QtGui.QVBoxLayout()
logo = QtGui.QLabel()
logo.setPixmap('./data/logo.png')
logo.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)
layout.addWidget(logo)
status_list = self.status_list = QtGui.QListWidget()
status_list.addItem('Chowdren, the blazingly fast runtime for '
'Clickteam Fusion.')
status_list.addItem(u'Copyright (c) Mathias K\xe6rlev 2012-2015.')
status_list.addItem('Applications made with Chowdren are subject to '
'the GNU General Public License.')
layout.addWidget(status_list)
self.setLayout(layout)
timer = QTimer(self)
timer.setInterval(100)
timer.timeout.connect(self.process_console)
timer.start()
self.process = process
self.output_queue = output_queue
self.input_queue = input_queue
self.log = open('chowdrenlog.txt', 'wb')
示例10: install
def install(app=None, timeout=0.02):
"""
Creates a :class:`~PySide.QtCore.QTimer` instance that will be triggered
continuously to call :func:`Engine.poll() <pants.engine.Engine.poll>`,
ensuring that Pants remains responsive.
========= ======== ============
Argument Default Description
========= ======== ============
app None *Optional.* The :class:`~PySide.QtCore.QCoreApplication` to attach to. If no application is provided, it will attempt to find an existing application in memory, or, failing that, create a new application instance.
timeout ``0.02`` *Optional.* The maximum time to wait, in seconds, before running :func:`Engine.poll() <pants.engine.Engine.poll>`.
========= ======== ============
"""
global timer
global _timeout
Engine.instance()._install_poller(_Qt())
if app is None:
app = QCoreApplication.instance()
if app is None:
app = QCoreApplication([])
_timeout = timeout * 1000
timer = QTimer(app)
timer.timeout.connect(do_poll)
timer.start(_timeout)
示例11: __init__
def __init__(self, parent):
super(QNEMainWindow, self).__init__(parent)
self.logger = logging.getLogger("zne")
self.logger.setLevel(logging.DEBUG)
self.setMinimumSize(560,360)
self.setWindowTitle("ZOCP Node Editor")
self.setWindowIcon(QIcon('assets/icon.png'))
self.scene = QGraphicsScene(self)
self.view = QGraphicsView(self)
self.view.setScene(self.scene)
self.setCentralWidget(self.view)
self.nodesEditor = QNodesEditor(self, self.scene, self.view)
self.nodesEditor.onAddConnection = self.onAddConnection
self.nodesEditor.onRemoveConnection = self.onRemoveConnection
self.nodesEditor.onBlockMoved = self.onBlockMoved
self.scale = 1
self.installActions()
self.initZOCP()
self.nodes = {}
self.pendingSubscribers = {}
QTimer.singleShot(250, lambda: self.scene.invalidate())
示例12: __init__
def __init__(self, parent=None):
# Set up everything
QMainWindow.__init__(self, parent)
self.setWindowTitle("USB4000 Control")
self.make_main_frame()
self.spectra_timer = QTimer()
self.spectra_timer.timeout.connect(self.update_spectrum)
self.temp_timer = QTimer()
self.temp_timer.timeout.connect(self.update_temp)
self.worker = Usb4000Thread()
self.wavelength_mapping = self.worker.dev.get_wavelength_mapping()
self.curves = []
self.persistence_sb.valueChanged.connect(self.change_persistence)
self.change_persistence()
self.background = 1
self.bg_min = 0
self.use_background = False
self.abs645 = pg.InfiniteLine(angle=90, movable=False)
self.abs663 = pg.InfiniteLine(angle=90, movable=False)
self.plot.addItem(self.abs645, ignoreBounds=True)
self.plot.addItem(self.abs663, ignoreBounds=True)
self.abs645.setPos(645)
self.abs663.setPos(663)
self.conc_deque = deque(maxlen=20)
示例13: __init__
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setWindowTitle("arrows")
self.resize(800, 600)
self.objects = []
self.circR = 20
self.arrSize = 10
self.direction = "down"
self.add(Circle(150, 150, self.circR))
self.flyer = Circle(300, 50, self.circR)
self.add(self.flyer)
self.add(Circle(600, 300, self.circR))
self.arrA = Arrow(150, 150, 300, 50, self.circR, self.arrSize)
self.add(self.arrA)
self.arrB = Arrow(300, 50, 600, 300, self.circR, self.arrSize)
self.add(self.arrB)
timer = QTimer(self)
timer.timeout.connect(self.frameUpdate)
timer.start(20)
示例14: __init__
def __init__(self):
global gEnableResourceMonitoring
self.enableResourceMonitoring = gEnableResourceMonitoring
self.bar = hiero.ui.mainWindow().statusBar()
self.updateMonitorIntervalMS = gUpdateIntervalMS # The monitor update time in milliseconds.
self.timer = QTimer()
self.timer.setSingleShot(False)
self.timer.timeout.connect(self.updateStatusBar)
self.currentDiskIOBytes = psutil.disk_io_counters().read_bytes
self.currentNetworkBytesReceived = psutil.net_io_counters().bytes_recv
# This observes the current pid (the App process id) via psutil, and reports back
if self.enableResourceMonitoring:
self.processHelper = PSUtilProcessWrapper()
# The frameServer instance
self.frameServerInstance = nukestudio.frameServer
# Initialise the Status Bar
self.setupUI()
# We haven't started monitoring at this point
self.isMonitoring = False
# Begin monitoring after a few secs to give frame server time to start up properly
QTimer.singleShot(gInitialDelayMS, self.startMonitoring)
示例15: wait_for_signal
def wait_for_signal(signal, timeout=10000):
"""Waits the given signal to be emitted, or breaks after a timeout
This context manager wraps a method of using a nested event loop to
wait for a signal, but additionally adds a timeout in case the signal
was prematurely emitted (in which case we will never catch it) or if
there is some kind of error and the signal is never emitted.
This context manager used here is inspired by code from a blob by John
Reaver, of which an archive can be found here:
https://web.archive.org/web/20160126155634/http://jdreaver.com/
posts/2014-07-03-waiting-for-signals-pyside-pyqt.html
"""
loop = QEventLoop()
# When the signal is caught, the loop will break
signal.connect(loop.quit)
# The content in the context manager will now be executed
# The timeout doesn't start until this block is finished, so make sure
# there is no blocking calls in the with block.
yield
if timeout is not None: # Not False as possible 0ms timeout would be False
QTimer.singleShot(timeout, loop.quit)
loop.exec_()