Sujet : Re: IDLE: clearing the screen
De : learn2program (at) *nospam* gmail.com (Alan Gauld)
Groupes : comp.lang.pythonDate : 09. Jun 2024, 20:06:07
Autres entêtes
Message-ID : <mailman.104.1717956371.2909.python-list@python.org>
References : 1 2
User-Agent : Mozilla Thunderbird
On 08/06/2024 20:18, Rob Cliffe via Python-list wrote:
OK, here is the advanced version:
import os
class _cls(object):
def __repr__(self):
os.system('cls')
return ''
cls = _cls()
Now when you type
cls
it clears the screen.
For me on a Mac it clears the terminal screen that I used
to launch IDLE and prints a single blank line on the IDLE
shell. (And I have to use "clear" instead of "cls" of course.
A quick Google suggests that printing Ctrl-L (formfeed?) might
be a platform agnostic solution. But that didn't work for me
in IDLE either. I think this is one where the best bet is to go
into the IDLE code and add a Shell submenu to clear screen!
Apparently it's been on the workstack at idle-dev for a long
time but is considered low priority...
-- Alan GAuthor of the Learn to Program web sitehttp://www.alan-g.me.uk/http://www.amazon.com/author/alan_gauldFollow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos