summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ryuslash2010-01-17 16:43:42 +0100
committerGravatar ryuslash2010-01-17 16:43:42 +0100
commite750aada186c2236a0cbc55d5503d5f4302860c3 (patch)
treed285d8786108f6bba0bb4bf0ed8372c96b665a4d
parent10f2f918a160ef9581290d1e72fb249db730bb2a (diff)
download4grab-e750aada186c2236a0cbc55d5503d5f4302860c3.tar.gz
4grab-e750aada186c2236a0cbc55d5503d5f4302860c3.zip
progress bar windows
* Made the progress bar 1 character smaller by default, good for windows CMD
-rw-r--r--progressbar.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/progressbar.py b/progressbar.py
index a2ea711..e7916e2 100644
--- a/progressbar.py
+++ b/progressbar.py
@@ -2,11 +2,12 @@ import sys
import time
class Progress():
- def __init__(self, maxvalue, maxwidth=80, fd=sys.stdout):
+ def __init__(self, maxvalue, maxwidth=79, fd=sys.stdout):
self.maxwidth = maxwidth
self.maxvalue = maxvalue
self.fd = fd
- self.fill_char = '#'
+ self.prog_char = '#'
+ self.fill_cahr = ' '
self.show_progress(0)
@@ -15,7 +16,7 @@ class Progress():
str_maxvalue = str(self.maxvalue)
true_maxwidth = self.maxwidth - 4 - len(str_value) - len(str_maxvalue)
progress = int(round((true_maxwidth/float(self.maxvalue))*value))
- self.fd.write("\r%s/%s [%s%s]" % (str_value, str_maxvalue, self.fill_char * progress, " " * (true_maxwidth - progress)))
+ self.fd.write("\r%s/%s [%s%s]" % (str_value, str_maxvalue, self.prog_char * progress, self.fill_char * (true_maxwidth - progress)))
self.fd.flush()
if value == self.maxvalue:
self.fd.write("\n")
@@ -24,4 +25,4 @@ if __name__ == "__main__":
prog = Progress(200)
for i in range(1, 201):
prog.show_progress(i)
- time.sleep(1)
+ time.sleep(0.1)