本文整理匯總了Python中PyQt4.QtCore.QThread方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QThread方法的具體用法?Python QtCore.QThread怎麽用?Python QtCore.QThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.QThread方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self):
super(WorkerStack, self).__init__()
self.workers = []
self.threads = []
self.load = {} # {'worker_name': tasks_count}
# Create workers crew
for i in range(0, 2):
worker = Worker(self, 'Slogger-' + str(i))
thread = QtCore.QThread()
worker.moveToThread(thread)
worker.connect(thread, QtCore.SIGNAL("started()"), worker.run)
worker.task_completed.connect(self.on_task_completed)
thread.start()
self.workers.append(worker)
self.threads.append(thread)
self.load[worker.name] = 0
示例2: main
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def main():
# Create Queue and redirect sys.stdout to this queue
queue = Queue()
sys.stdout = StdoutQueue(queue)
# Start the main GUI class
app = QtGui.QApplication(sys.argv)
form = MainWindow()
form.show()
# Create thread that will listen for new strings in the queue. Upon new
# items, Receiver will emit a signal, which will be sent to the
# onDataReady method in the MainWindow class. The onDataReady method
# will add the string to the text editor in the GUI.
thread = QtCore.QThread()
receiver = Receiver(queue)
receiver.signal.connect(form.onDataReady)
receiver.moveToThread(thread)
thread.started.connect(receiver.run)
thread.start()
sys.exit(app.exec_())
示例3: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self, srv, layer, extent, zoom, outFile, outCRS, seedOnly, recurseUpZoomLevels):
QtCore.QThread.__init__(self, None)
self.srv = srv
self.layer = layer
self.extent = extent
self.outFile = outFile
self.outCRS = outCRS
self.seedOnly = seedOnly
if recurseUpZoomLevels and seedOnly:
self.zoom = list(range(self.srv.layers[self.layer].zmin, zoom+1))
self.rq = BBoxRequestMZ(self.srv.srcTms, self.extent, self.zoom)
print(self.rq.nbTiles, self.srv.srcTms.bboxRequest(self.extent, zoom).nbTiles)
else:
self.zoom = zoom
self.rq = self.srv.srcTms.bboxRequest(self.extent, self.zoom)
示例4: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self, parent=None, target=None, args=()):
"""
This class is meant for heavy lifing that has to happen in a separate
thread, to keep the UI responding. It will take a callable `target'
and execute it in a separate thread with the given `args'. Please
note that a reference to the thread object will be pre-pendend to the
arguments list passed to th callable, to allow acces to the methods
provided by this class to modify the progress bar used to show the
user the progress of the work executed in the thread.
"""
QtCore.QThread.__init__(self, parent)
self.target = target
self.args = (self,) + args
示例5: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self):
QtCore.QThread.__init__(self, parent=None)
self.urls = []
self.processing = False
示例6: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self, cmdQueue):
QtCore.QThread.__init__(self)
self.running = True
self.cmdQueue = cmdQueue
self.limitDelta = 1.0 / 60.0 # 60fps
self.delta = 0.0
self.lastTime = 0.0
示例7: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self):
QtCore.QThread.__init__(self)
self.run_loop = True
# Helps ensure that the thread quits before it's destroyed.
示例8: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self):
QtCore.QThread.__init__(self)
示例9: run
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def run(self):
QtCore.QThread.sleep(4)
print('Done sleeping')
示例10: main
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def main(argv=None):
app = None
# create the application if necessary
if not QtGui.QApplication.instance():
app = QtGui.QApplication(argv)
app.setQuitOnLastWindowClosed(True)
app.setOrganizationName("GGPO")
QtCore.QCoreApplication.setApplicationName("GGPO")
ColorTheme.saveDefaultStyle()
controller = Controller()
thread = QtCore.QThread()
controller.moveToThread(thread)
thread.started.connect(controller.selectLoop)
thread.start()
def loggedIn():
controller.connectUdp()
window = GGPOWindow()
window.setWindowIcon(QtGui.QIcon(':/assets/icon-128.png'))
window.setController(controller)
window.restorePreference()
controller.sendListChannels()
window.show()
window.raise_()
window.activateWindow()
logindialog = LoginDialog()
logindialog.setController(controller)
logindialog.accepted.connect(loggedIn)
logindialog.rejected.connect(sys.exit)
logindialog.exec_()
logindialog.raise_()
logindialog.activateWindow()
return app.exec_()
示例11: run
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def run(cls, checkonly, statusMsgCallback=None, finishedCallback=None):
if cls._thread:
logdebug().error('Already has a download thread running')
cls._thread = QtCore.QThread()
cls._worker = SyncWorker(checkonly)
cls._worker.moveToThread(cls._thread)
if finishedCallback:
cls._worker.sigFinished.connect(finishedCallback)
cls._worker.sigFinished.connect(cls.cleanup)
if statusMsgCallback:
cls._worker.sigStatusMessage.connect(statusMsgCallback)
cls._thread.started.connect(cls._worker.download)
cls._thread.start()
示例12: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self, icon, parent=None):
QtGui.QSystemTrayIcon.__init__(self, icon, parent)
menu = QtGui.QMenu(parent)
s = os.popen("nsaway --plugins").read().split("\n")
# Magic
s = s[2].split("[")[1].replace("]", "").split(", ")
s = [si.replace("'","") for si in s]
# It's clean
# Plugin
for item in s:
entry = menu.addAction(item)
self.connect(entry,QtCore.SIGNAL('triggered()'), lambda item=item: self.exec_plugin(item))
# Finished plugin loading
menu.addSeparator()
changeicon = menu.addAction("Reset Status")
menu.addSeparator()
exitAction = menu.addAction("Exit")
self.setContextMenu(menu)
exitAction.triggered.connect(self.quit)
changeicon.triggered.connect(self.reset_icon)
self.thread = QtCore.QThread()
self.listener = Listener()
self.listener.moveToThread(self.thread)
self.thread.started.connect(self.listener.loop)
self.listener.message.connect(self.signal_received)
QtCore.QTimer.singleShot(0, self.thread.start)
示例13: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self,parent=None,win_info=None):
QtCore.QThread.__init__(self,parent)
self.win_info=win_info
self.parent=parent
示例14: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self,parent=None):
QtCore.QThread.__init__(self,parent)
self.parent=parent
示例15: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self, ip, port, parent = None):
QtCore.QThread.__init__(self, parent)
self.ip = ip
self.port = port