Python Idle Configure Clear screen shortcut (CTRL+L)

Source: Internet
Author: User
Tags clear screen

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)

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.