cls

A

Art McClure

May I ask a dumb question? I am working with Python 2.3 IDLE. I want
to completely clear the screen except for the ">>>", of course. What
do I use? I have tried a number of suggestions, but they don't do the
job.
 
J

Jeff Epler

This change makes printing the formfeed character, '\f', clear the shell
window in idle. I don't know if it also has other undesirable
consequences (I'm not an idle user, and I don't have the patience to do
much testing). Given this,
def cls():
print '\f'


Index: Lib/idlelib//OutputWindow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/OutputWindow.py,v
retrieving revision 1.10
diff -u -r1.10 OutputWindow.py
--- Lib/idlelib//OutputWindow.py 9 Jul 2003 18:48:24 -0000 1.10
+++ Lib/idlelib//OutputWindow.py 29 Feb 2004 01:30:34 -0000
@@ -35,6 +35,13 @@
# Act as output file

def write(self, s, tags=(), mark="insert"):
+ if "\x0c" in s:
+ print "OutputWindow.write saw ^L"
+ self.text.mark_unset("iomark")
+ s = s.split("\x0c")[-1]
+ print "new s: ", s
+ self.text.delete(0.0, "end")
+ self.text.mark_set("iomark", 0.0)
# Tk assumes that byte strings are Latin-1;
# we assume that they are in the locale's encoding
if isinstance(s, str):
 

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
474,183
Messages
2,570,967
Members
47,520
Latest member
KrisMacono

Latest Threads

Top