Python源码示例:PySide2.QtCore.QTimer()

示例1
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
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
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
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
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
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
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
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
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
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
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
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_())