Lines Matching +full:timer +full:- +full:width

1 # -*- coding: utf-8 -*-
3 # progressbar - Text progress bar library for Python.
6 # SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause-Clear
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
61 pbar - a reference to the calling ProgressBar
66 """The base class for all variable width widgets.
70 all have the same width, and together will fill the line.
74 def update(self, pbar, width): argument
75 """Updates the widget providing the total width the widget must fill.
77 pbar - a reference to the calling ProgressBar
78 width - The total width the widget must fill
82 class Timer(Widget): class
104 class ETA(Timer):
113 return 'ETA: --:--:--'
118 eta = elapsed * pbar.maxval / pbar.currval - elapsed
122 class AdaptiveETA(Timer):
146 return elapsed * maxval / float(currval) - elapsed
151 return 'ETA: --:--:--'
159 etasamp = self._eta(pbar.maxval - currval1,
160 pbar.currval - currval1,
161 elapsed - elapsed1)
163 eta = (1 - weight) * eta + weight * etasamp
180 if pbar.seconds_elapsed < 2e-6 or pbar.currval < 2e-6: # =~ 0
197 def __init__(self, markers='|/-\\'):
199 self.curmark = -1
233 class FormatLabel(Timer):
237 'elapsed': ('seconds_elapsed', Timer.format_time),
286 marker - string or updatable object to use as a marker
287 left - string or updatable object to use as a left border
288 right - string or updatable object to use as a right border
289 fill - character to use for the empty part of the progress bar
290 fill_left - whether to fill from the left or the right
299 def update(self, pbar, width): argument
305 width -= len(left) + len(right)
308 marked *= int(pbar.currval / pbar.maxval * width)
313 return '%s%s%s' % (left, marked.ljust(width, self.fill), right)
315 return '%s%s%s' % (left, marked.rjust(width, self.fill), right)
325 marker - string or updatable object to use as a marker
326 left - string or updatable object to use as a left border
327 right - string or updatable object to use as a right border
328 fill - character to use for the empty part of the progress bar
329 fill_left - whether to fill from the left or the right
339 def update(self, pbar, width): argument
345 width -= len(left) + len(right)
347 if pbar.finished: return '%s%s%s' % (left, width * marker, right)
349 position = int(pbar.currval % (width * 2 - 1))
350 if position > width: position = width * 2 - position
351 lpad = self.fill * (position - 1)
352 rpad = self.fill * (width - len(marker) - len(lpad))
367 self.curmark = -1
370 def update(self, pbar, width): argument
374 width -= len(left) + len(right)
375 if width < 0:
378 if pbar.finished: return '%s%s%s' % (left, width * '=', right)
381 position = int(self.curmark % (width * 2 - 1))
382 if position + len(marker) > width:
386 lpad = ' ' * (position - 1)
387 rpad = ' ' * (width - len(marker) - len(lpad))