Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing a line at the bottom of the console/terminal

Using Python, I would like to print a line that will appear on the last visible line on the console the script is being ran from. For example, something like this:

enter image description here

Would this be able to be done?

like image 735
Markum Avatar asked May 27 '12 12:05

Markum


2 Answers

The easiest way is to use effbot.org's Console module:

import Console

c = Console.getconsole()
c.text(0, -1, 'And this is the string at the bottom of the console')

By specifying -1 for the second (line) argument you are addressing the last line of the console.

Because the Console module only works on Windows, to get this to work on UNIX terminals as well, you should take a look at the wcurses library, which provides a partial curses implementation that'll work on Windows. You'd drive it the same as the stdlib curses module; use the first on Windows, the latter on UNIX.

like image 75
Martijn Pieters Avatar answered Nov 19 '22 13:11

Martijn Pieters


For a Windows terminal try the console module For unix the curses module would do.

like image 28
ditkin Avatar answered Nov 19 '22 12:11

ditkin