def get_progress(self, set=False):
"""
Return progress (between 0 and 1 - 0 is full blue control,
1 is full green control) and optionally set the current
progress.
"""
# TODO: wtf is this thing, and why are we setting values in
# a getter. Should this be refactored into two functions
# called `update_progress` and `get_progress` instead?
rate = self.rate_value
if rate == 0.0 or self.start is None:
return self.progress
dt = reactor.seconds() - self.start
progress = max(0, min(1, self.progress + rate * dt))
if set:
self.progress = progress
return progress
评论列表
文章目录