0

I want to setup a progressBar until end of the execution of a particular method.

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

method on_click_uploadAndTest takes considerable time to execute. Meanwhile progressBar should visualize the execution progress.

UPDATE:

result is a String array. predict() method in 'predictwithUI.py' gives output of string array (result). 'predictwithUI.py' predicts characters in a given image using a trained neural network model.

If number of characters in a given image is large then it takes considerable time to give the output. So I want to setup progressBar until predict() gives output.

Ishara Madhawa
  • 3,549
  • 5
  • 24
  • 42
  • Which class is `self.progressBar` an instance of? –  Apr 11 '18 at 12:54
  • `Ui_MainWindow` which is in file TeamInsight.py – Ishara Madhawa Apr 11 '18 at 12:56
  • @IsharaMadhawa provides a [mcve] of the function on_click_uploadAndTest, if it takes a long time the most appropriate option would be to use a new thread. – eyllanesc Apr 11 '18 at 17:46
  • @eyllanesc I updated the question. Now you can get a descriptive idea about function on_click_uploadAndTest. – Ishara Madhawa Apr 12 '18 at 02:29
  • @IsharaMadhawa QProgressBar only shows the progress, it does not calculate it, so your job is to calculate it, for example let's say you do 10 tasks, each time that a task ends it would be 10%, can you calculate the progress? – eyllanesc Apr 12 '18 at 02:34
  • 2
    @IsharaMadhawa For you to understand better check the following posts: https://stackoverflow.com/questions/49631464/pyqt-qprogressbar-not-working-when-i-use-it-with-selenuim/49637095#49637095 and https://stackoverflow.com/a/49647769/6622587 – eyllanesc Apr 12 '18 at 02:36
  • @eyllanesc I understood. Thank you for the explanation. I need to implement a way to calculate the progress. – Ishara Madhawa Apr 12 '18 at 02:52

0 Answers0