Clearing IDLE's screen?

Kurt B. Kaiser kbk at shore.net
Sun Feb 8 20:48:44 CET 2004


miki.tebeka at zoran.com (Miki Tebeka) writes:

> I'd like to bind <CTRL+L> so that it will clear IDLE's screen (in the
> interactive prompt).
> Any pointers/suggetions?

Try this:

def clear():
    for i in range(60):
        print

If that is adequate, then you should be able to write an extension
for IDLE which would bind this function to a key.

Read .../idlelib/extend.txt for further information.

Note that if you use this approach, previous entries into the Shell
window can be retrieved by scrolling up and/or using the "View Last
Restart / F6" feature.  This is useful to recall code to the command
line for re-evaluation.

The downside is the buffer can get pretty large.  You have to decide
if that's a problem.  It hasn't been for me.  If you have an Edit
window open, you can always close the Shell window occasionally and
reopen it from the Run menu.

If you really want to clear the buffer for the Shell window, then the
Tkinter Text widget would have to be truncated.  That involves a
deeper understanding of IDLE, particularly EditWindow.py,
OutputWindow.py, and PyShell.py.  It is conceivable that it could be
done as an extension.


===

I have been planning on implementing an integrated Shell Clear
capability in IDLE 1.1 which would truncate the Shell Text widget.
Just re-opening the Shell window would probably move it on the screen,
so that is not very attractive.

The question for the list is, should Clear be orthogonal to Reset or
should Clear also do a Reset?

Other comments?

-- 
KBK



More information about the Python-list mailing list