Only draw the advanced progress bar if 'num_pieces' is greater than 0.

This commit is contained in:
Andrew Resch 2008-02-01 21:18:58 +00:00
parent 7a973947a7
commit 4b18f49ec1
1 changed files with 10 additions and 9 deletions

View File

@ -94,15 +94,16 @@ class DetailsTabManager(object):
gc.set_foreground(colormap.alloc_color('#2020FF')) gc.set_foreground(colormap.alloc_color('#2020FF'))
progress_window.draw_rectangle(gc, True, 0, top, int(size[0] * state['progress']), 4) progress_window.draw_rectangle(gc, True, 0, top, int(size[0] * state['progress']), 4)
num_pieces = state["total_wanted"] / state["piece_length"] num_pieces = state["total_wanted"] / state["piece_length"]
for pieces_range in state['pieces']: if num_pieces > 0:
range_first = pieces_range[0] * size[0] / num_pieces for pieces_range in state['pieces']:
range_length = ((pieces_range[1] - pieces_range[0] + 1) * size[0] / num_pieces) range_first = pieces_range[0] * size[0] / num_pieces
if range_length == 0: range_length = ((pieces_range[1] - pieces_range[0] + 1) * size[0] / num_pieces)
range_length = 1 if range_length == 0:
gc.set_foreground(colormap.alloc_color('#8080FF')) range_length = 1
else: gc.set_foreground(colormap.alloc_color('#8080FF'))
gc.set_foreground(colormap.alloc_color('#2020FF')) else:
progress_window.draw_rectangle(gc, True, range_first, top + 5, range_length, height - 5) gc.set_foreground(colormap.alloc_color('#2020FF'))
progress_window.draw_rectangle(gc, True, range_first, top + 5, range_length, height - 5)
gc.set_foreground(colormap.alloc_color('dim gray')) gc.set_foreground(colormap.alloc_color('dim gray'))
progress_window.draw_line(gc, 0, top, 0, top + height) progress_window.draw_line(gc, 0, top, 0, top + height)
progress_window.draw_line(gc, 0, top, size[0], top) progress_window.draw_line(gc, 0, top, size[0], top)