def collectNoise(self, seconds): """ Collect noise data and update ``noiseData``. Uses the processes/threads started in :func:`startSnifferAndAdder`. :param seconds: Amount of seconds to capture noise :return: True if noise was captured. False if the user pressed "Cancel" """ self.noiseData = [] # Setup the ProgressDialog progressDialog = QProgressDialog( Strings.filterTabCollectingNoiseMessageBoxText, "Cancel", 0, seconds) progressDialog.setMinimumDuration(0) progressDialog.setMinimum(0) progressDialog.setMaximum(seconds) progressDialog.adjustSize() progressDialog.setFixedSize(progressDialog.width() + 40, progressDialog.height()) # Users still can click on the "X" progressDialog.setCancelButton(None) # Start collecting self.startSnifferAndAdder(adderMethod=self.addSniffedNoise) progressDialog.open() secondsToCollect = seconds while secondsToCollect > 0 and not progressDialog.wasCanceled(): time.sleep(0.5) secondsToCollect -= 0.5 self.updateNoiseCollectProgress(progressDialog, seconds - secondsToCollect) self.stopSnifferAndAdder() return not progressDialog.wasCanceled()