pythonpyqt5从特定方法执行的开始到结束的progressBar可视化

2024-05-02 11:27:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我想设置一个progressBar,直到特定方法的执行结束。在

class MainWindow(QMainWindow, TeamInsight.Ui_MainWindow):
        def __init__(self, parent=None):
            super(MainWindow, self).__init__(parent)
            self.setupUi(self)

        def on_click_uploadAndTest(self):
            self.progressBar.setHidden(False)
            self.progressBar.setEnabled(True)

            self.statusbar.showMessage("Testing in progress...")
            result = predictwithUI.predict(self.image_path)

            # Display the output code is here

方法on_click_uploadAndTest需要相当长的时间才能执行。同时,progressBar应该可视化执行进度。在

更新:

结果是一个字符串数组。predict()方法在'predictwithUI.py'给出字符串数组的输出(结果)。'predictwithUI.py'使用训练过的神经网络模型预测给定图像中的字符。在

如果给定图像中的字符数很大,则需要相当长的时间才能给出输出。 所以我想设置progressBar直到predict()给出输出。在


Tags: 方法字符串selfinitondef时间数组