1

I know I can use either print \b to replace a single character or sys.stdout.write(\rSomething) to replace an entire line of text (like in this example), but is there a way replace the top line in the console window using Python while letting text continue to print below?

For example:

[----       ]     <-- a progress bar that updates at the top...
Ongoing info      <-- while other stuff prints down below
foo
More ongoing info
Community
  • 1
  • 1
JeffThompson
  • 1,538
  • 3
  • 24
  • 47

1 Answers1

1

It's more complex that just using characters, as you need more powerful control over terminal.

This may sources for help:

If you're really want to go hard way and do it using RAW control, you have to learn about ANSI control code (well known as Escape sequences). However - you have been warned - that way is not portable as different terminal types use in fact slightly different sequences to control what and how is displayed in terminal and some terminal doesn't support some codes and then certain operations are handled different way. Using curses solve these problems for you.

Michał Fita
  • 1,183
  • 1
  • 7
  • 24