There is a function (LoadData) for loading large data (taken from the database (SQlite)) into a text file ( fout ) with filling in the corresponding indicator ( self.ui.progressBar ). When executing the function, the window application starts “Not responding” and freezes (since the cycle time is ~ 3 minutes depending on the size of data ) while the cycle is being executed ( for line in data ). Accordingly, the indicator value all this time is 0%. What are the solutions to this problem?
def LoadData(self, data): nof = self.ui.lineEdit_22.text() + '.txt' #Имя файла вводит пользователь fout = open(nof, 'w') self.step = 0 #Значение индикатора percent = len(data)/100 #Количество строк в 1% coun = 0 #Счётчик строк for line in data: for i in range(10): fout.write(str(line[i])) fout.write(' ') fout.write('\n') coun = coun + 1 if coun == percent: coun = 0 self.step = self.step + 1 self.ui.progressBar.setValue(self.step) fout.close()