On 6/16/05, <b class="gmail_sendername">Don Parris</b> <<a href="mailto:webdev@matheteuo.org">webdev@matheteuo.org</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Thanks! I thought there had to be a way to call the OS' clear screen<br>command, but was going about it the wrong way. I was trying to use<br>sys.clear instead of os.system. Would it be difficult to test the OS,<br>
store the result in a variable, and call the comand based on the variable<br>result? Or would it be simpler to have users edit the script for their OS?<br><br>Mind you, there may be other areas where I need an OS-specific command. I'm
<br>beginning to get an idea of the challenges of portability though. ;)<br><br>Don<br></blockquote></div><br>
You might want to use the tput command. It returns control
sequences for the terminal that are used by all programs, e.g. emacs,
vi(m). Your could capture the output with the commands module and
send it to the terminal with stdout.write (instead of print).<br>
<br>
<span style="font-family: courier new,monospace;">import commands<br>
<br>
clear_str = None<br>
def clearscreen():<br>
global clear_str<br>
from sys import stdout<br>
if not clear_str:<br>
clear_str = commands.getoutput('tput clear')<br>
stdout.write(clear_str)<br>
<br>
clearscreen()<br>
</span><br>
If you wanted, you could encapsulate this into a module or a
class. This would work on just about any UNIX/Linux/BSD system,
and might work on Mac OS/X (I don't know if they use terminfo).<br>
<br>
You can use the other tput subcommands in your program if you wished as
well. (Hide the cursor, go to column X row Y, etc.)<br>
-Arcege<br>-- <br>There's so many different worlds,<br>So many different suns.<br>And we have just one world,<br>But we live in different ones.