def clear(self): if self.show_numbers: return if self.show_progressbar: w, _ = getTerminalSize() else: w = len(self.pbar_str) sys.stdout.write(" " * len(self.pbar_str[:w]) + "\r") sys.stdout.flush() # force updating of screen
def draw(self): # draw progress bar - but only if it has changed if self._changed: self._changed = False if self.show_progressbar: w, _ = getTerminalSize() else: w = len(self.pbar_str) if self.show_numbers: print(self.pbar_str[:w]) return sys.stdout.write(self.pbar_str[:w] + "\r") sys.stdout.flush() # force updating of screen