Any Way to Clear Python's Idle Window

Clearing the screen of IDLE interactive mode

cls and clear are commands which will clear a terminal (ie a DOS prompt, or terminal window). If you are using the shell within IDLE, which won't be affected by such things, a workaround might be to print a lot of empty lines with print("\n" * 100). See also this answer for more information.

How to clear screen on python 3.6 IDLE?

The "cls" and "clear" are commands which will clear a terminal (ie a DOS prompt, or terminal window). From your screenshot, you are using the shell within IDLE, which won't be affected by such things. Unfortunately, I don't think there is a way to clear the screen in IDLE. The best you could do is to scroll the screen down lots of lines, eg:

print "\n" * 100

Though you could put this in a function:

def cls(): print "\n" * 100

And then call it when needed as cls()

source: Any way to clear python's IDLE window?

How to clear the screen of ALL text in IDLE shell?

That is not possible with IDLE's Python shell.

From the documentation:

Shell never throws away output.

and

Tab characters cause the following text to begin after the next tab stop. (They occur every 8 ‘characters’). Newline characters cause following text to appear on a new line. Other control characters are ignored or displayed as a space, box, or something else, depending on the operating system and font.

Meaning it's a very basic shell that outputs all text in a linear fashion. You need to run Python in a different shell to accomplish what you want.

How to clear Python Shell in IDLE

By python shell, do you mean IDLE? Some quick googling suggests that IDLE doesn't have a clear screen even though lots of people seem to want one. If it's in a shell, then I'm surprised 'cls' isn't working.

If you like working in Idle, you might look at this for getting the functionality you want:
http://idlex.sourceforge.net/extensions.html#ShellEnhancements
The internet seems to think you should just stop using IDLE, however.

clear python idle using command

You can use os to clear the window if you're using command line. Note that the windows version does not work in Idle, only in the Python shell. If you are using windows, the best way might be to simply output the appropriate number of empty lines.

import os

os.system('clear')
os.system('CLS') # windows

# Solution for IDLE
N = 40 # you might need to adjust this
for i in range(N):
print "\n"

Clear screen in shell

For macOS/OS X, you can use the subprocess module and call 'cls' from the shell:

import subprocess as sp
sp.call('cls', shell=True)

To prevent '0' from showing on top of the window, replace the 2nd line with:

tmp = sp.call('cls', shell=True)

For Linux, you must replace cls command with clear

tmp = sp.call('clear', shell=True)


Related Topics



Leave a reply



Submit