Is it possible to print a line at a specific position on the screen inside IDLE?

EDIT: I just found that you can get similar behavior using the standard curse library. There are several demos on how this works here and there, for example on YouTube: http://www.youtube.com/watch?v=Bj-H9uPEa5U

This is a strange and stupid question that I know, but I'm curious because I don't know anything about python and how it works. From the terminal, or when you use IDLE, is there a way to print a line at a specific position on the screen?

I will try to explain it better: do you remember the old days when you made small programs in Basic, perhaps on Commodore 64, Apple II or ZX Spectrum? During these days, if you want to print a line at a specific position, you used to write something like this:

10 LOCATE 30, 40: PRINT "Hello World"

I am just curious to know if there is a way to tell python to print the lines at a specific position, and if there is a way to find out how many columns and how many lines can actually be displayed in the IDLE window.

Since English is not my native language, I also made a layout to explain this concept a little better :-)

Thanks.

Mockup screen to explain what I mean

+6
source share
1 answer

I don't know if this works in IDLE, but it works in any regular terminal:

import sys def print_there(x, y, text): sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text)) sys.stdout.flush() 

It uses Ansi-Escape Sequences

+13
source

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


All Articles