En Mon, 29 Oct 2007 17:31:52 -0300, Shawn Minisall  
<[EMAIL PROTECTED]> escribió:

> Hmm...it works fine within the command line but then when I import os in
> python and then try os.system("cls"), i get that very fast
> opening/closing window and 0 inside the shell.

Try the other method menctioned in the Knowledge Base article:

<code>
"""
How To Performing Clear Screen (CLS) in a Console Application

 From http://support.microsoft.com/kb/99261

Some non-Microsoft versions of C++ provide a clrscr function
for clearing the screen in a DOS application. However, there
is no Win32 Application Programming Interface (API) or
C-Runtime function that will perform this function.
To accomplish this task for a Win32 console application, use
one of the following methods:
- os.system("cls")
- Write a function that will programmatically clear the screen

The following function is my (GG) Python translation of the
original C code as published in the Microsoft article, using
Mark Hammond's pywin32 extensions:
"""

import win32api
import win32console

def cls():
     "Clear console screen"
     TopLeft = win32console.PyCOORDType(0,0)
     csb = win32console.GetStdHandle(win32api.STD_OUTPUT_HANDLE)
     csbi = csb.GetConsoleScreenBufferInfo()
     size = csbi['Size'].X * csbi['Size'].Y;
     csb.FillConsoleOutputCharacter(u' ', size, TopLeft)
     csb.FillConsoleOutputAttribute(csbi['Attributes'], size, TopLeft);
     csb.SetConsoleCursorPosition(TopLeft)

</code>

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to