1. Under Python\lib\idlelib, create a new clearwindow.py file (new when not created) with the following content:
"" "Clear Window extensionversion:0.2author:roger D. Serwy [Email protected]date:2009-06-14it provides" Clea R Shell Window "under" options with ability to undo. Add these lines to config-extensions.def[clearwindow]enable=1enable_editor=0enable_shell=1[clearwindow_cfgbindings ]clear-window=<control-key-l> "" "Class clearwindow:menudefs = [(' Options ', [None], (' Clear S Hell Window ', ' <<clear-window>> '),] def __init__ (self, editwin): Self.editwin = E Ditwin Self.text = Self.editwin.text self.text.bind ("<<clear-window>>", Self.clear_window2) Self.text.bind ("<<undo>>", self.undo_event) # add= "+" doesn ' t work def undo_event (Self, event): Text = Self.text Text.mark_set ("Iomark2", "Iomark") Text.mark_set ("Insert2", "Insert") SELF.E Ditwin.undo.undo_event (Event) # fix Iomark and insert Text.mark_set ("Iomark", "IOMARK2") Text.mark_set ("Insert", "Insert2") Text.mark_unset ("Iomark2") Text.mark_unset ("Insert2") def clear_window2 (self, event): # Alternative Method # work around the modifiedundodelegator text = Self.tex T Text.undo_block_start () text.mark_set ("Iomark2", "Iomark") Text.mark_set ("Iomark", 1.0) text . Delete (1.0, "Iomark2 Linestart") text.mark_set ("Iomark", "Iomark2") Text.mark_unset ("Iomark2") text. Undo_block_stop () If Self.text.compare (' Insert ', ' < ', ' Iomark '): Self.text.mark_set (' Insert ', ' end-1c ') Self.editwin.set_line_and_column () def clear_window (Self, event): # Remove undo Delegator Undo = Self.editwin.undo Self.editwin.per.removefilter (undo) # Clear the window, but preserve current command Self.text.delete (1.0, "Iomark linestart") if Self.text.compare (' Insert ', ' < ', ' Iomark '): Self.tex T.mark_set (' Insert ', ' enD-1c ') self.editwin.set_line_and_column () # Restore Undo Delegator Self.editwin.per.insertfilter (und O
2.python\lib\idlelib under Modify Config-extensions.def, add the following at the end:
1[clearwindow]enable=1enable_editor=0enable_shell=1[clearwindow_cfgbindings]clear-window=<control-key-l>
3. Re-python idle, in the options option you can see the addition of the clear Shell Window ctrl+l, that is, the shortcut keys for clear screen: ctrl+l
Python Idle Configure Clear screen shortcut (CTRL+L)