Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions progressbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ def update(self, value=None):
self.last_update_time = now


def start(self):
'''Starts measuring time, and prints the bar at 0%.
def start(self, initval=0):
'''Starts measuring time, initialize the progresbar at 0 (or the optional initval)
and prints the bar at the appropriate percentage.

It returns self so you can use it like this:
>>> pbar = ProgressBar().start()
Expand All @@ -298,12 +299,13 @@ def start(self):
self.next_update = 0

if self.maxval is not UnknownLength:
if self.maxval < 0: raise ValueError('Value out of range')
if self.maxval < 0 or initval > self.maxval:
raise ValueError('Value out of range')
self.update_interval = self.maxval / self.num_intervals


self.start_time = self.last_update_time = time.time()
self.update(0)
self.update(initval)

return self

Expand Down