I'd like to do a console progress-bar in Python using \r to clear the display. To support multi-line progress-bars (for several parallel tasks) I am wondering if one can set terminal width for the current process so that long lines would wrap?
For instance if I set terminal width to 20, I could do my progress-bar in this way:
print '\r%-20s%-20s' % ('Task 1: 30%', 'Task 2: 60%'),
time.sleep(1)
print '\r%-20s%-20s' % ('Task 1: 35%', 'Task 2: 65%'),
I'm aware one can use ncurses (or progress-bar packages using ncurses) for that, I'm just wondering if there's a solution not using ncurses.
I have tried set_winsize from https://stackoverflow.com/a/6420070/445810, but it didn't work, and line still didn't wrap.
Thanks!