clear screen / locate cursor

P

Peter

I am just trying to learn python, to use for some fairly basic command
line utilities which will run in either Windows/DOS or Linux. I cannot
find a platform neutral way of manipulating the screen. I don't want
to do anything complex, but just:-

1. Clear the screen
2. Print a string at an arbitrary x,y position
3. Receive a single key stroke

It seems that under Linux the curses module will do all this and more
(though I haven't tried it), but despite Python documentation curses
does not seem to be available under DOS. I have solved the 'clear
screen' problem with the code below, but made no progress on the other
two:-

def cls():
a=os.name
if a=='posix': #linux
os.system('clear')
elif a=='nt': #windows
os.system('cls')
else: #unknown
print
print ('='*(78-len(a)))+a
print

Is this the best solution? Can anyone help with the others? I have
tried searching python documentation and this newsgroup, but found no
pointers. It can't be difficult (for the experts!) - other cross
platform languages such as Yabasic and Euphoria seem to have such a
facility, so what am I missing?

The email address above was genuine once but has long been abandoned
to spam. Pleae reply via newsgroup or to

peter dot mosley at spamguardnorth dot org after removing spamguard

Thanks in advance for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,113
Latest member
Vinay KumarNevatia
Top