mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add tests for PyQt debugging
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
from PyQt5 import QtCore
|
||||
import sys
|
||||
|
||||
|
||||
class AThread(QtCore.QThread):
|
||||
|
||||
def run(self):
|
||||
for i in range(3):
|
||||
print("ping %d" % i)
|
||||
|
||||
app = QtCore.QCoreApplication([])
|
||||
thread = AThread()
|
||||
thread.finished.connect(app.exit)
|
||||
thread.start()
|
||||
sys.exit(app.exec_())
|
||||
@@ -0,0 +1,23 @@
|
||||
from PyQt5 import QtCore
|
||||
import sys
|
||||
|
||||
|
||||
class SomeObject(QtCore.QObject):
|
||||
|
||||
finished = QtCore.pyqtSignal()
|
||||
|
||||
def longRunning(self):
|
||||
for i in range(3):
|
||||
print("ping %d" % i)
|
||||
self.finished.emit()
|
||||
|
||||
|
||||
app = QtCore.QCoreApplication([])
|
||||
objThread = QtCore.QThread()
|
||||
obj = SomeObject()
|
||||
obj.moveToThread(objThread)
|
||||
obj.finished.connect(objThread.quit)
|
||||
objThread.started.connect(obj.longRunning)
|
||||
objThread.finished.connect(app.exit)
|
||||
objThread.start()
|
||||
sys.exit(app.exec_())
|
||||
@@ -0,0 +1,19 @@
|
||||
from PyQt5 import QtCore
|
||||
import sys
|
||||
|
||||
|
||||
class Runnable(QtCore.QRunnable):
|
||||
|
||||
def run(self):
|
||||
app = QtCore.QCoreApplication.instance()
|
||||
for i in range(3):
|
||||
print("ping %d" % i)
|
||||
app.quit()
|
||||
|
||||
|
||||
app = QtCore.QCoreApplication([])
|
||||
runnable = Runnable()
|
||||
QtCore.QThreadPool.globalInstance().start(runnable)
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user