當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QThread方法代碼示例

本文整理匯總了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 
開發者ID:Denvi,項目名稱:FlatCAM,代碼行數:23,代碼來源:FlatCAMWorkerStack.py

示例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_()) 
開發者ID:camisatx,項目名稱:pySecMaster,代碼行數:25,代碼來源:main_gui.py

示例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) 
開發者ID:domlysz,項目名稱:BlenderGIS,代碼行數:18,代碼來源:QtMapServiceClient.py

示例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 
開發者ID:linuxscout,項目名稱:mishkal,代碼行數:15,代碼來源:appgui.py

示例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 
開發者ID:SECFORCE,項目名稱:sparta,代碼行數:6,代碼來源:auxiliary.py

示例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 
開發者ID:ubuntunux,項目名稱:PyEngine3D,代碼行數:10,代碼來源:MainWindow.py

示例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. 
開發者ID:pyskell,項目名稱:slouchy,代碼行數:7,代碼來源:slouchy.py

示例8: __init__

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def __init__(self):
		QtCore.QThread.__init__(self) 
開發者ID:PacktPublishing,項目名稱:ROS-Programming-Building-Powerful-Robots,代碼行數:4,代碼來源:robot_gui.py

示例9: run

# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QThread [as 別名]
def run(self):
        QtCore.QThread.sleep(4)
        print('Done sleeping') 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:5,代碼來源:_debugger_case_qthread4.py

示例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_() 
開發者ID:doctorguile,項目名稱:pyqtggpo,代碼行數:38,代碼來源:main.py

示例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() 
開發者ID:doctorguile,項目名稱:pyqtggpo,代碼行數:15,代碼來源:unsupportedsavestates.py

示例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) 
開發者ID:TheZ3ro,項目名稱:nsaway,代碼行數:30,代碼來源:tray.py

示例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 
開發者ID:the-duck,項目名稱:launcher,代碼行數:6,代碼來源:Window.py

示例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 
開發者ID:the-duck,項目名稱:launcher,代碼行數:5,代碼來源:Main.py

示例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 
開發者ID:kakaroto,項目名稱:SWProxy,代碼行數:6,代碼來源:gui.py


注:本文中的PyQt4.QtCore.QThread方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。