QProgressTaskDialog.py 文件源码

python
阅读 109 收藏 0 点赞 0 评论 0

项目:PyQt5-CWidgets 作者: ArmPitPerson 项目源码 文件源码
def __init__(self, taskName):
        """Constructor for QProgressTaskDialog

        Arguments:
        string taskName -- Title of the window and label before progress bar

        Example:
        W = QProgressTaskDialog("Clearing Forest")
        for i in range(100):
            if not W.isCancelled():
                W.setProgress(i + 1)
            else:
                W.close()
        """

        super().__init__()

        self.setGeometry(800, 400, 600, 70)
        self.setWindowTitle(taskName)

        self.__taskLabel = QtWidgets.QLabel(self)
        self.__taskLabel.setText(taskName)

        self.__subTaskLabel = QtWidgets.QLabel(self)
        self.__subTaskLabel.setText("Working...")

        self.__progressBar = QtWidgets.QProgressBar(self)

        self.__cancelButton = QtWidgets.QPushButton(self)
        self.__cancelButton.clicked.connect(self.__cancelTask)
        self.__cancelButton.setText("Cancel")

        __hLayout = QtWidgets.QHBoxLayout()
        __hLayout.addWidget(self.__taskLabel)
        __hLayout.addWidget(self.__progressBar)
        __hLayout.addWidget(self.__cancelButton)

        __vLayout = QtWidgets.QVBoxLayout(self)
        __vLayout.addLayout(__hLayout)
        __vLayout.addWidget(self.__subTaskLabel)
        __vLayout.addStretch()

        self.setLayout(__vLayout)

        self.__cancelled = False
        self.__progress = 0
        self.__maxProgress = 100
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号