Exemplo n.º 1
0
 def _handle_disconnect(self):
     self.con.deleteLater()
     QCoreApplication.quit()
Exemplo n.º 2
0
from qt.QtCore import (QThread, QObject, QCoreApplication, QMetaObject, Qt,
                       Slot, Signal, QRunnable, QThreadPool)


class Job(QObject):

    finished = Signal()

    @Slot()
    def run(self):
        print("job thread: %d" % QThread.currentThreadId())
        self.finished.emit()


def finished():
    print("post thread: %d" % QThread.currentThreadId())


if __name__ == '__main__':
    import sys
    app = QCoreApplication(sys.argv)
    print("main thread: %d" % QThread.currentThreadId())
    thread = QThread()
    thread.start()
    job = Job()
    job.finished.connect(finished, Qt.QueuedConnection)
    job.moveToThread(thread)
    QMetaObject.invokeMethod(job, 'run', Qt.QueuedConnection)
    app.exec_()
    thead.wait()
Exemplo n.º 3
0
        self.hotkey = Hotkey(self.handle_hotkey)

    def handle_hotkey(self):
        self.fire.emit()

    def stop(self):
        self.hotkey.stop()

    def run(self):
        self.hotkey.start()


if __name__ == '__main__':
    import sys
    import os
    logging.basicConfig(
        filename=os.path.expanduser('~/.lit.server.log'),
        filemode='w',
        format='%(asctime)s - %(levelname)s - %(message)s',
        level=logging.DEBUG
    )
    app = QCoreApplication(sys.argv)
    set_app_info(app, 'litserver')
    server = Server()
    QMetaObject.invokeMethod(
        server,
        'start',
        Qt.QueuedConnection
    )
    sys.exit(app.exec_())
Exemplo n.º 4
0
    QThreadPool
)


class Job(QObject):

    finished = Signal()

    @Slot()
    def run(self):
        print("job thread: %d" % QThread.currentThreadId())
        self.finished.emit()


def finished():
    print("post thread: %d" % QThread.currentThreadId())


if __name__ == '__main__':
    import sys
    app = QCoreApplication(sys.argv)
    print("main thread: %d" % QThread.currentThreadId())
    thread = QThread()
    thread.start()
    job = Job()
    job.finished.connect(finished, Qt.QueuedConnection)
    job.moveToThread(thread)
    QMetaObject.invokeMethod(job, 'run', Qt.QueuedConnection)
    app.exec_()
    thead.wait()