diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c00f68..1923b21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +Version 2.11.0 +================ +- Use only 1 line to print the progress bar (instead of the previous too lines) + + Version 2.10.0 ================ - Fixes an issue with Jupyter Notebook 4.3.1 when the `ETA` got printed on new lines diff --git a/pyprind/__init__.py b/pyprind/__init__.py index f969ade..fb3fd61 100644 --- a/pyprind/__init__.py +++ b/pyprind/__init__.py @@ -17,4 +17,4 @@ from .generator_factory import prog_bar -__version__ = '2.10.0' +__version__ = '2.11.0' diff --git a/pyprind/progbar.py b/pyprind/progbar.py index e3ecb96..d57ee6e 100755 --- a/pyprind/progbar.py +++ b/pyprind/progbar.py @@ -50,7 +50,6 @@ def __init__(self, iterations, track_time=True, width=30, bar_char='#', self._adjust_width() self.bar_char = bar_char self.last_progress = 0 - self._print_labels() if monitor: try: @@ -71,16 +70,13 @@ def _adjust_width(self): # reported that self.max_iter was converted to # float. Thus this fix to prevent float multiplication of chars. - def _print_labels(self): - self._stream_out('0% {} 100%\n'.format(' ' * (self.bar_width - 6))) - self._stream_flush() - def _cache_progress_bar(self, progress): remaining = self.bar_width - progress - self._cached_output += '[{}{}]'.format(self.bar_char * int(progress), + self._cached_output += '0% [{}{}] 100%'.format(self.bar_char * int(progress), ' ' * int(remaining)) def _print(self, force_flush=False): + self._stream_flush() progress = floor(self._calc_percent() / 100 * self.bar_width) if self.update_interval: do_update = time.time() - self.last_time >= self.update_interval diff --git a/pyprind/progpercent.py b/pyprind/progpercent.py index f584bbf..8102cc9 100755 --- a/pyprind/progpercent.py +++ b/pyprind/progpercent.py @@ -57,6 +57,7 @@ def _cache_percent_indicator(self, last_progress): def _print(self, force_flush=False): """ Prints formatted percentage and tracked time to the screen.""" + self._stream_flush() next_perc = self._calc_percent() if self.update_interval: do_update = time.time() - self.last_time >= self.update_interval