[Tutor] clearing lines for a 'front end' to a tool

Alan Gauld alan.gauld at btinternet.com
Tue Sep 16 02:42:21 CEST 2008

"James" <jtp at nc.rr.com> wrote

> I'm writing a 'front end' which will show a list of the "things" 
> that
> are currently happening in the background in a simple
> (non-interactive) interface. Here's an idea of what the terminal 
> will
> look like when the program is running.

The critical piece of missing info is which platform/OS we
are dealing with. Anyy kind of terminal control is going to be
platform dependant - which is why curses may not be overkill!
(except it doesn't work well on Windows)

> The question here is mostly about how to generate this output. The
> bottom line (the 'status') *always* remains at the bottom of the

This is where terminal control comes in and a lot depends on
what terninal you are using.

> I'm unsure how to go about doing this... I imagine that the ANSI
> "clear line" value may be helpful

That would work on Windows but most *nix consoles don't use
the ANSI codes consistently, most will be haoppier with DEC VT
control codes (or Tektronics or Wyse). Thats where curses helps
by hiding all that stuff.

If on *nix use curses or any of several other console UI  libraries.
On Windows use native ANSI codes and/or the Conio library.

Several other options here:


Although many may be outdated now.

Finally, this would be very easy to do in a Tkinter GUI.
All you need is a containing frame, a text widget and a label and
either a timer or a callback structure from your threads bto trigger
updates. Probably easier than using a terninal interface!


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list