码迷,mamicode.com
首页 > 编程语言 > 详细

python的IDEL编辑器清屏文件配置

时间:2019-01-20 14:04:32      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:添加   快捷   splay   set   ons   undo   文件   快捷键   lines   

1.找到Python\PythonX\Lib\idlelib(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)
ClearWindow.py

 

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编辑器清屏文件配置

标签:添加   快捷   splay   set   ons   undo   文件   快捷键   lines   

原文地址:https://www.cnblogs.com/chaiquan/p/10294420.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!