Java教程

PyQt5线程队列------LinkNode

本文主要是介绍PyQt5线程队列------LinkNode,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import sys
import os

from PyQt5.QtCore import QObject
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QGuiApplication

"""模块路径加到当前模块扫描的路径里"""
sys.path.append(os.path.dirname(__file__))
# import numpy as np
# import cv2
"""
@项目 :ThreadLoop
@文件 :LinkNode.py    
@作者 :xsh
@时间 :2021/11/21 15:20
@功能 :
@说明 :

"""
from myThread import myThread, DrawInfo


class LinkNode(QObject):
    """当前节点的编号"""
    CurrentThreadNumber: int
    """当前节点线程"""
    CurrentThread: myThread
    """上一个节点"""
    LastNode: 'LinkNode'
    """下一个节点"""
    NextNode: 'LinkNode'

    def __init__(self, number=int(0), parent=None):
        super(LinkNode, self).__init__(parent)
        self.CurrentThreadNumber = number
        self.CurrentThread = myThread(self.CurrentThreadNumber, None)
        self.LastNode = None
        self.NextNode = None
    def __del__(self):
        if self.CurrentThread:
            self.CurrentThread.Stop(True)
            self.CurrentThread.deleteLater()
    """停止当前节点的线程"""
    def Stop(self):
        self.CurrentThread.Stop(True)
        while self.CurrentThread.isRunning():
            pass
        pass
    """暂停当前节点的线程"""
    def Pause(self):
        if self.CurrentThread.getPause():
            return
        else:
            self.CurrentThread.Pause(True)
        pass
    """启动当前节点的线程"""
    def Start(self, *args):
        self.CurrentThread.Start(*args)
        pass
    """线程是否空闲"""
    def isFree(self) -> bool:
        return self.CurrentThread.getPause()

    """线程是否在运行"""
    def isRunning(self) -> bool:
        return self.CurrentThread.getStop() is False

 

这篇关于PyQt5线程队列------LinkNode的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!