Public Member Functions | |
def | update |
Definition at line 111 of file progressbar.py.
def progressbar::BouncingBar::update | ( | self, | |
pbar, | |||
width | |||
) |
Updates the widget providing the total width the widget must fill. pbar - a reference to the calling ProgressBar width - The total width the widget must fill
Reimplemented from progressbar::Bar.
Definition at line 112 of file progressbar.py.
00113 : 00114 'Updates the progress bar and its subcomponents' 00115 00116 left, marker, right = (format_updatable(i, pbar) for i in 00117 (self.left, self.marker, self.right)) 00118 00119 width -= len(left) + len(right) 00120 00121 if pbar.finished: return '%s%s%s' % (left, width * marker, right) 00122 00123 position = int(pbar.currval % (width * 2 - 1)) 00124 if position > width: position = width * 2 - position 00125 lpad = self.fill * (position - 1) 00126 rpad = self.fill * (width - len(marker) - len(lpad)) 00127 00128 # Swap if we want to bounce the other way 00129 if not self.fill_left: rpad, lpad = lpad, rpad 00130 00131 return '%s%s%s%s%s' % (left, lpad, marker, rpad, right)