Created
January 14, 2015 18:29
-
-
Save wkentaro/a3fd2883d663f1ea428f to your computer and use it in GitHub Desktop.
perfect multi cmdline refreshing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# multi2.py | |
# author: Kentaro Wada <[email protected]> | |
import curses | |
import time | |
def report_progress(filename, progress): | |
"""progress: 0-10""" | |
stdscr.addstr(0, 0, "Moving file: {0}".format(filename)) | |
stdscr.addstr(1, 0, "Total progress: [{1:10}] {0}%".format(progress * 10, "#" * progress)) | |
stdscr.refresh() | |
if __name__ == "__main__": | |
stdscr = curses.initscr() | |
curses.noecho() | |
curses.cbreak() | |
try: | |
for i in range(10): | |
report_progress("file_{0}.txt".format(i), i+1) | |
time.sleep(0.5) | |
finally: | |
curses.echo() | |
curses.nocbreak() | |
curses.endwin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to execute it.
$ git clone https://gist.github.com/wkentaro/a3fd2883d663f1ea428f multi2 $ cd multi2 $ python multi2.py