a size-intelligent progress bar?

Michael Stenner mstenner at phy.duke.edu
Wed Apr 9 13:55:07 EDT 2003


On Wed, Apr 09, 2003 at 06:20:02PM +0100, Tom Chance wrote:
> Hullo,
> 
> I'm making a shell-based program that includes a progress bar (like wget's
> one). At the moment, I've got it printing an equals sign every 2% so I get
> a progress bar 50 "="s wide, which fits my Konsole perfectly. This isn't
> very handy for other shell sizes though :)
> 
> Does anyone have, or can anyone point me in the direction of a way of making
> a decent progress bar that will automagically detect the width of the shell
> open, even resizing it mid-"progress"?

I don't know how portable it is, but the environment variable COLUMNS
appears to tell me my terminal width and follows resizes.  If you
check that on each update, it should do what you want.

				-Michael
-- 
  Michael Stenner                       Office Phone: 919-660-2513
  Duke University, Dept. of Physics       mstenner at phy.duke.edu
  Box 90305, Durham N.C. 27708-0305





More information about the Python-list mailing list