Print a line at the bottom of the console / terminal

Using Python, I would like to print a line that appears in the last visible line on the console that the script is running with. For example, something like this:

enter image description here

Can this be done?

+6
source share
2 answers

The easiest way is to use the effbot.org 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 (linear) argument, you are accessing the last line of the console.

Since the Console module only works on Windows, to make this work on UNIX terminals as well, you should take a look at the wcurses library , which provides a partial curses implementation that will run on Windows. You will manage it in the same way as the stdlib curses module ; use the first on Windows and the second on UNIX.

+1
source

For a Windows terminal, try the console module. For unix, the curses module will be used.

+1
source

Source: https://habr.com/ru/post/916783/


All Articles