[Tutor] Wondering if there is a print in location command for terminal?

Alan Gauld alan.gauld at btinternet.com
Tue Feb 10 01:40:49 CET 2015


On 09/02/15 18:03, dw wrote:
> Hi Python Gang,
> In the olden days of Basic, there was a "Locate" command to locate
> strings in specific x/y locations on the terminal.
>
> For example:
> Locate 9,10:print "THE POWER OF PYTHON"
> Would count down from top of terminal 9 increments.
> And the count (from left to right of terminal) 10 spaces.
> Then print the string there.
>
> I wonder if what I'm looking for is the "Curses" library?
> I'm running Python 2.6 in Linux and 2.7 in Window.

Yes curses is probably the best fit here. It doesn't work
so well on Windows but on Linux/MacOS it does a good job.
Just remember that Terminals come in all sorts of shapes
and sizes so curses can only do its best to adjust things.

There are some other library packages that emulate the
old DOS conio package and include x/y coordinate location,
but they often require ANSI.SYS or similar to be installed.
And they are all third party rather than being standard
library items like curses.

There are lots of curses tutorials out there. The C ones
should be quite usable since the curses calls are pretty
much a straight mapping to the C library.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list