Python IDLE adds clear screen function

Source: Internet
Author: User
Tags clear screen

Save the following code to clearwindow.py

"" "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 = Editwin 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 = s Elf.text text.mark_set ("Iomark2", "Iomark") Text.mark_set ("Insert2", "Insert") self.editwin.u        Ndo.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 Clea        R_window2 (self, event): # Alternative Method # work around the modifiedundodelegator text = Self.text 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_blo        Ck_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.E Ditwin.undo Self.editwin.per.removefilter (undo) # Clear the window, but preserve-command self . Text.delete (1.0, "Iomark linestart") if Self.text.compare (' Insert ', ' < ', ' Iomark '): self.text.mark_s  ET (' Insert ', ' end-1c ')      Self.editwin.set_line_and_column () # Restore undo Delegator Self.editwin.per.insertfilter (undo)  

Save the above file to C:\Python27\Lib\idlelib. Then open the Config-extensions.def file in this directory and add the following code to its tail

################################# >>> Added for Clear Window[clearwindow]enable=1enable_editor=0enable_ Shell=1[clearwindow_cfgbindings]clear-window=<control-key-l>

OK, now IDLE can support ctrl+l clear the screen.

Finish.

Python IDLE adds clear screen function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.