File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -117,12 +117,17 @@ def progress(self, value):
117117 ), "Progress value must be a floating point value."
118118 if self ._progress_val > value :
119119 # uncolorize range from width*value+margin to width-margin
120- for _w in range (int (value * self ._width + 2 ), self ._width - 2 ):
120+ # from right to left
121+ _prev_pixel = max (2 , int (self ._width * self ._progress_val - 2 ))
122+ _new_pixel = max (int (self ._width * value - 2 ), 2 )
123+ for _w in range (_prev_pixel , _new_pixel - 1 , - 1 ):
121124 for _h in range (2 , self ._height - 2 ):
122125 self ._bitmap [_w , _h ] = 0
123126 else :
124- # fully fill progress bar color
125- for _w in range (2 , self ._width * value - 2 ):
127+ # fill from the previous x pixel to the new x pixel
128+ _prev_pixel = max (2 , int (self ._width * self ._progress_val - 3 ))
129+ _new_pixel = min (int (self ._width * value - 2 ), int (self ._width * 1.0 - 3 ))
130+ for _w in range (_prev_pixel , _new_pixel + 1 ):
126131 for _h in range (2 , self ._height - 2 ):
127132 self ._bitmap [_w , _h ] = 2
128133 self ._progress_val = value
Original file line number Diff line number Diff line change 2727
2828current_progress = 0.0
2929while True :
30- while current_progress <= 1.0 :
31- print ("Progress: {}%" .format (current_progress * 100 ))
32- progress_bar .progress = current_progress
33- current_progress += 0.05
34- if current_progress >= 1.0 :
35- current_progress = 0.0
30+ # range end is exclusive so we need to use 1 bigger than max number that we want
31+ for current_progress in range (0 , 101 , 1 ):
32+ print ("Progress: {}%" .format (current_progress ))
33+ progress_bar .progress = current_progress / 100 # convert to decimal
3634 time .sleep (0.01 )
35+ time .sleep (0.3 )
36+ progress_bar .progress = 0.0
37+ time .sleep (0.3 )
You can’t perform that action at this time.
0 commit comments