本文整理匯總了Python中PySide2.QtCore.QTimer方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QTimer方法的具體用法?Python QtCore.QTimer怎麽用?Python QtCore.QTimer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PySide2.QtCore
的用法示例。
在下文中一共展示了QtCore.QTimer方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: show
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def show(self, exec_widget=True):
super(Viewer, self).show()
self.viewAll()
rec = self.app.desktop().screenGeometry()
self.move(rec.width() - self.size().width(),
rec.height() - self.size().height())
if not exec_widget:
timer = QtCore.QTimer()
# timer.timeout.connect(self.close)
timer.singleShot(20, self.close)
self.app.exec_()
try:
from IPython.display import Image
return Image(self.name)
except ImportError as e:
print(e)
示例2: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def __init__(self):
QObject.__init__(self, None)
self._mainthread = QThread.currentThread()
self._signalthread = SignalThread()
QObject.connect(self._signalthread, SIGNAL("triggerSignal()"),
self.sensorQueueChanged)
self._idletimer = QTimer()
self._delaytimer = QTimer()
self._timerqueuetimer = QTimer()
self._idletimer.setSingleShot(True)
self._delaytimer.setSingleShot(True)
self._timerqueuetimer.setSingleShot(True)
self.connect(self._idletimer, SIGNAL("timeout()"), self.idleTimeout)
self.connect(self._delaytimer, SIGNAL("timeout()"), self.delayTimeout)
self.connect(self._timerqueuetimer, SIGNAL("timeout()"), self.timerQueueTimeout)
SoDB.getSensorManager().setChangedCallback(self.sensorQueueChangedCB, self)
SoDB.setRealTimeInterval(1.0 / 25.0)
SoRenderManager.enableRealTimeUpdate(False)
示例3: _setCanvas
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def _setCanvas(self, speed, title, width, height):
self.speed = speed
self.width = width
self.height = height
self.canvas = QtGui.QPainter()
self.canvasWidget = CanvasWidget()
self.canvasWidget.setWindowTitle(title)
self.canvasWidget.setFixedSize(width, height)
self.canvasWidget.show()
self.timer = QtCore.QTimer()
self.timer.setInterval(speed)
self.timer.start()
self.timer.timeout.connect(self.canvasWidget.update)
示例4: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def __init__(self):
self.logger = logging_util.SporeLogger(__name__)
self.timer = QTimer()
self.timer.timeout.connect(self.send_report)
self.last_msg = 0.0
self.msg_stack = []
示例5: sensorQueueChangedCB
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def sensorQueueChangedCB(self, closure):
# if we get a callback from another thread, route the callback
# through SignalThread so that we receive the callback in the
# QApplication thread (needed since QTimer isn't thread safe)
if QThread.currentThread() != closure._mainthread:
if not closure._signalthread.isRunning():
closure._signalthread.start()
self._signalthread.trigger()
else:
self.sensorQueueChanged()
示例6: queue_text_change
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def queue_text_change(ui, text: str) -> None:
global text_timer
if text_timer:
text_timer.stop()
text_timer = QTimer()
text_timer.setSingleShot(True)
text_timer.timeout.connect(partial(update_button_text, ui, text))
text_timer.start(500)
示例7: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.counter = 0
layout = QVBoxLayout()
self.l = QLabel("Start")
b = QPushButton("DANGER!")
b.pressed.connect(self.oh_no)
layout.addWidget(self.l)
layout.addWidget(b)
w = QWidget()
w.setLayout(layout)
self.setCentralWidget(w)
self.show()
self.threadpool = QThreadPool()
print(
"Multithreading with maximum %d threads" % self.threadpool.maxThreadCount())
self.timer = QTimer()
self.timer.setInterval(1000)
self.timer.timeout.connect(self.recurring_timer)
self.timer.start()
示例8: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def __init__(self, button_text: str, copy_text: str):
super(CopyButton, self).__init__()
self.copy_text = copy_text
self.button_text = button_text
self.button = QPushButton(button_text)
# noinspection PyUnresolvedReferences
self.button.clicked.connect(self.copy)
self.addWidget(self.button)
self.timer = QTimer(self.parentWidget())
示例9: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def __init__(self):
super(SpendTab, self).__init__()
self.initUI()
self.taker = None
self.filter_offers_response = None
self.clientfactory = None
self.tumbler_options = None
#timer for waiting for confirmation on restart
self.restartTimer = QtCore.QTimer()
#timer for wait for next transaction
self.nextTxTimer = None
#tracks which mode the spend tab is run in
self.spendstate = SpendStateMgr(self.toggleButtons)
self.spendstate.reset() #trigger callback to 'ready' state
示例10: useQt
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def useQt(qtLib: str = 'PyQt5', period: float = 0.01):
"""
Run combined Qt5/asyncio event loop.
Args:
qtLib: Name of Qt library to use, can be 'PyQt5' or 'PySide2'.
period: Period in seconds to poll Qt.
"""
def qt_step():
loop.call_later(period, qt_step)
if not stack:
qloop = QEventLoop()
timer = QTimer()
timer.timeout.connect(qloop.quit)
stack.append((qloop, timer))
qloop, timer = stack.pop()
timer.start(0)
qloop.exec_()
timer.stop()
stack.append((qloop, timer))
if qtLib not in ('PyQt5', 'PySide2'):
raise RuntimeError(f'Unknown Qt library: {qtLib}')
if qtLib == 'PyQt5':
from PyQt5.Qt import QApplication, QTimer, QEventLoop
else:
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QTimer, QEventLoop
global qApp
qApp = QApplication.instance() or QApplication(sys.argv) # type: ignore
loop = asyncio.get_event_loop()
stack: list = []
qt_step()
示例11: __init__
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def __init__(self, renderer, glformat, app):
"Creates an OpenGL context and a window, and acquires OpenGL resources"
super(MyGlWidget, self).__init__(glformat)
self.renderer = renderer
self.app = app
# Use a timer to rerender as fast as possible
self.timer = QTimer(self)
self.timer.setSingleShot(True)
self.timer.setInterval(0)
self.timer.timeout.connect(self.render_vr)
# Accept keyboard events
self.setFocusPolicy(Qt.StrongFocus)
示例12: start
# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QTimer [as 別名]
def start(_exit: bool = False) -> None:
app = QApplication(sys.argv)
logo = QIcon(LOGO)
main_window = MainWindow()
ui = main_window.ui
main_window.setWindowIcon(logo)
tray = QSystemTrayIcon(logo, app)
tray.activated.connect(main_window.systray_clicked)
menu = QMenu()
action_exit = QAction("Exit")
action_exit.triggered.connect(app.exit)
menu.addAction(action_exit)
tray.setContextMenu(menu)
ui.text.textChanged.connect(partial(queue_text_change, ui))
ui.command.textChanged.connect(partial(update_button_command, ui))
ui.keys.textChanged.connect(partial(update_button_keys, ui))
ui.write.textChanged.connect(partial(update_button_write, ui))
ui.change_brightness.valueChanged.connect(partial(update_change_brightness, ui))
ui.switch_page.valueChanged.connect(partial(update_switch_page, ui))
ui.imageButton.clicked.connect(partial(select_image, main_window))
ui.brightness.valueChanged.connect(partial(set_brightness, ui))
for deck_id, deck in api.open_decks().items():
ui.device_list.addItem(f"{deck['type']} - {deck_id}", userData=deck_id)
build_device(ui)
ui.device_list.currentIndexChanged.connect(partial(build_device, ui))
ui.pages.currentChanged.connect(partial(change_page, ui))
ui.actionExport.triggered.connect(partial(export_config, main_window))
ui.actionImport.triggered.connect(partial(import_config, main_window))
timer = QTimer()
timer.timeout.connect(partial(sync, ui))
timer.start(1000)
api.render()
tray.show()
main_window.show()
if _exit:
return
else:
sys.exit(app.exec_())