python的IDEL编辑器清屏文件配置
Posted chaiquan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python的IDEL编辑器清屏文件配置相关的知识,希望对你有一定的参考价值。
1.找到PythonPythonXLibidlelib(x为你的版本号),在当前目录下添加ClearWindow.py,复制提供的代码,保存为*.py即可。
1 class ClearWindow: 2 3 menudefs = [ 4 (‘options‘, [None, 5 (‘Clear Shell Window‘, ‘<<clear-window>>‘), 6 ]),] 7 8 def __init__(self, editwin): 9 self.editwin = editwin 10 self.text = self.editwin.text 11 self.text.bind("<<clear-window>>", self.clear_window2) 12 13 self.text.bind("<<undo>>", self.undo_event) # add="+" doesn‘t work 14 15 def undo_event(self, event): 16 text = self.text 17 18 text.mark_set("iomark2", "iomark") 19 text.mark_set("insert2", "insert") 20 self.editwin.undo.undo_event(event) 21 22 # fix iomark and insert 23 text.mark_set("iomark", "iomark2") 24 text.mark_set("insert", "insert2") 25 text.mark_unset("iomark2") 26 text.mark_unset("insert2") 27 28 29 def clear_window2(self, event): # Alternative method 30 # work around the ModifiedUndoDelegator 31 text = self.text 32 text.undo_block_start() 33 text.mark_set("iomark2", "iomark") 34 text.mark_set("iomark", 1.0) 35 text.delete(1.0, "iomark2 linestart") 36 text.mark_set("iomark", "iomark2") 37 text.mark_unset("iomark2") 38 text.undo_block_stop() 39 if self.text.compare(‘insert‘, ‘<‘, ‘iomark‘): 40 self.text.mark_set(‘insert‘, ‘end-1c‘) 41 self.editwin.set_line_and_column() 42 43 def clear_window(self, event): 44 # remove undo delegator 45 undo = self.editwin.undo 46 self.editwin.per.removefilter(undo) 47 48 # clear the window, but preserve current command 49 self.text.delete(1.0, "iomark linestart") 50 if self.text.compare(‘insert‘, ‘<‘, ‘iomark‘): 51 self.text.mark_set(‘insert‘, ‘end-1c‘) 52 self.editwin.set_line_and_column() 53 54 # restore undo delegator 55 self.editwin.per.insertfilter(undo)
2.在当前目录下找到config-extensions.def 并修改,在末尾添加如下代码:
[ClearWindow] enable=True enable_editor=False enable_shell=True [ClearWindow_cfgBindings] clear-window=<Control-Key-l>
3. 重新打开IDEL即可,如果快捷键无效的话,注意查看ClearWindow.py的大小写以及配置文件内容的大小写状态
以上是关于python的IDEL编辑器清屏文件配置的主要内容,如果未能解决你的问题,请参考以下文章
Python 2.7.3 IDEL中输入多行代码时,如何回车? x = raw_input("Enter Name:") print "Hey" + x