1

I have a set of functions that when they run can take a few minutes to finish. I want to display a progress bar while they are running. I have a run function for now that just sleeps for x amount of time

def run(self, n):
    for i in range(n):
        time.sleep(.05)
        self.ui.progressBar.setValue(i+1)

and then in my main I have

def run_gui(self):
    self.ui.progressBar = QProgressBar()
    n = 50
    self.ui.progressBar.setMinimum(0)
    self.ui.progressBar.setMaximum(n)
    layout = QVBoxLayout()
    layout.addWidget(self.ui.progressBar)

    self.ui.pb_tester_connect_disconnect.clicked.connect(lambda: self.run(n))

eventually I am going to change this so that instead of calling 'self.run' I will call the functions that need to run. My question is, how do I get the progress bar to show up while this function runs? Do I need to add to run? Or add to my main?

Luke
  • 138
  • 2
  • 11

0 Answers0