I haven't found anything about this, but maybe that's because it isn't possible. But is there a way to print text to coordinates in Python? For example, if I wanted to print the string 'A' at the 3rd row and 5th column of the command window, how could I do that? I found ways to get around it and print two different strings at different coordinates using \n for rows and repeating spaces for columns, but it's just too tedious to write the code.
This is possible. The curses library comes standard and is documented here. There are probably others but that will do what you're looking for. In particular, curses.getsyx()
might be what you need.
If you want to avoid the curses module, you can get right down to the basics by using ANSI escape sequences. A quick explanation of the relevant cursor-moving codes can be found here. These work right out of the box on Linux/Unix, for Windows you'll need the coloroma package.
For a cute, cross-platform example using this technique for animation, see here.
def printCorrdinate(myString, x, y):
George 2012-04-04 22:45