Clearing IDLE's screen?

M

Miki Tebeka

Hello All,

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

Thanks.
Miki
 
K

Kurt B. Kaiser

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?
 
M

Miki Tebeka

Hell Kurt,
Try this:

def clear():
for i in range(60):
print
I'd like to clear the history as well.
The downside is the buffer can get pretty large. You have to decide
if that's a problem. It hasn't been for me.
I've found that when the buffer is very big IDLE becomes very slow.
(Happes to me a lot, instead of
)

The question for the list is, should Clear be orthogonal to Reset or
should Clear also do a Reset?
IMO it should just clear. I'd like it to remember my previous
definition and just clear the screen.

Miki
 
S

Scott David Daniels

Kurt said:
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?

It should be separate. When I run something with a print spewing
far more information than I expected, I want to wipe the output.
I'd really like to just cut that part out, but clearing the text
buffer is good enough. On the other hand, I often want to repeat
the commands I just typed with slight variations. I really wouldn't
like to lose those just because I typed the name of a hopelessly
large array.
 

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
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top