-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgressBar.py
More file actions
37 lines (32 loc) · 910 Bytes
/
ProgressBar.py
File metadata and controls
37 lines (32 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
import sys
class progressbar:
def __init__(self,toolbar_width=10):
self.toolbar_width=toolbar_width
sys.stdout.write("[%s]" % (" " * toolbar_width))
sys.stdout.flush()
sys.stdout.write("\b" * (toolbar_width+1)) # return to start of line, after '['
pass
def go(self,i,n):
#print 'n,self.toolbar_width',n, self.toolbar_width
x=int(n/self.toolbar_width)
if x==0:
sys.stdout.write("*")
sys.stdout.flush()
elif (i % x)==0:
sys.stdout.write("*")
sys.stdout.flush()
pass
if i==(n-1): sys.stdout.write("\n")
pass
pass
if __name__=='__main__':
pb=progressbar(10)
try:
n=int(sys.argv[1])
except:
n=100000
pass
for i in range(n):
pb.go(i,n)
pass