By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,965 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

Clearing IDLE's screen?

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
mi*********@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
Jul 18 '05 #2

P: n/a
Hell Kurt,
I'd like to bind <CTRL+L> so that it will clear IDLE's screen (in the
interactive prompt). 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
print len(open("X").read()) I do print open("X").read()

)
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
Jul 18 '05 #3

P: n/a
Kurt B. Kaiser wrote:
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.

--
-Scott David Daniels
Sc***********@Acm.Org
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.