我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用progressbar.SimpleProgress()。
def progressbarize(iterable, progress=False): """Construct progressbar for loops if progressbar requested, otherwise return directly iterable. :param iterable: iterable to use :param progress: True if print progressbar """ if progress: # The casting to list is due to possibly yielded value that prevents # ProgressBar to compute overall ETA return progressbar.ProgressBar(widgets=[ progressbar.Timer(), ', ', progressbar.Percentage(), ', ', progressbar.SimpleProgress(), ', ', progressbar.ETA() ])(list(iterable)) return iterable
def progress_bar(n): import progressbar return progressbar.ProgressBar( max_value=n, widgets=[ progressxbar.Percentage(), ' ', '(', progressbar.SimpleProgress(), ')', ' ', progressbar.Bar(), ' ', progressbar.AdaptiveETA(), ]) # http://code.activestate.com/recipes/577058/
def _init_pbar(self, ini_val, max_val, label): self._pbar = progressbar.ProgressBar( min_value=0, max_value=max_val, initial_value=ini_val, widgets=[ label, progressbar.Percentage(), '(', progressbar.SimpleProgress(), ')', progressbar.Bar(), progressbar.Timer(), ' ', '|', progressbar.ETA(), ] ) self._pbar.start()
def iterator_progress_bar(iterator, maxval=None): """ Returns an iterator for an iterator that renders a progress bar with a countdown timer. """ from progressbar import ProgressBar, SimpleProgress, Bar, ETA pbar = ProgressBar( maxval=maxval, widgets=[SimpleProgress(sep='/'), ' ', Bar(), ' ', ETA()], ) return pbar(iterator)