博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python IDLE配置清屏快捷键(Ctrl+L)
阅读量:7152 次
发布时间:2019-06-29

本文共 2709 字,大约阅读时间需要 9 分钟。

1.在Python\Lib\idlelib下,新建一个ClearWindow.py文件(没有时就新建),内容如下:

1 """ 2  3 Clear Window Extension 4 Version: 0.2 5  6 Author: Roger D. Serwy 7         roger.serwy@gmail.com 8  9 Date: 2009-06-1410 11 It provides "Clear Shell Window" under "Options"12 with ability to undo.13 14 Add these lines to config-extensions.def15 16 [ClearWindow]17 enable=118 enable_editor=019 enable_shell=120 [ClearWindow_cfgBindings]21 clear-window=
22 23 24 """25 26 class ClearWindow:27 28 menudefs = [29 ('options', [None,30 ('Clear Shell Window', '<
>'),31 ]),]32 33 def __init__(self, editwin):34 self.editwin = editwin35 self.text = self.editwin.text36 self.text.bind("<
>", self.clear_window2)37 38 self.text.bind("<
>", self.undo_event) # add="+" doesn't work39 40 def undo_event(self, event):41 text = self.text42 43 text.mark_set("iomark2", "iomark")44 text.mark_set("insert2", "insert")45 self.editwin.undo.undo_event(event)46 47 # fix iomark and insert48 text.mark_set("iomark", "iomark2")49 text.mark_set("insert", "insert2")50 text.mark_unset("iomark2")51 text.mark_unset("insert2")52 53 54 def clear_window2(self, event): # Alternative method55 # work around the ModifiedUndoDelegator56 text = self.text57 text.undo_block_start()58 text.mark_set("iomark2", "iomark")59 text.mark_set("iomark", 1.0)60 text.delete(1.0, "iomark2 linestart")61 text.mark_set("iomark", "iomark2")62 text.mark_unset("iomark2")63 text.undo_block_stop()64 if self.text.compare('insert', '<', 'iomark'):65 self.text.mark_set('insert', 'end-1c')66 self.editwin.set_line_and_column()67 68 def clear_window(self, event):69 # remove undo delegator70 undo = self.editwin.undo71 self.editwin.per.removefilter(undo)72 73 # clear the window, but preserve current command74 self.text.delete(1.0, "iomark linestart")75 if self.text.compare('insert', '<', 'iomark'):76 self.text.mark_set('insert', 'end-1c')77 self.editwin.set_line_and_column()78 79 # restore undo delegator80 self.editwin.per.insertfilter(undo)81

2.Python\Lib\idlelib下修改config-extensions.def ,在末尾添加如下内容:

1[ClearWindow]2 enable=13 enable_editor=04 enable_shell=15 [ClearWindow_cfgBindings]6 clear-window=

3.重新Python的IDLE,在options选项中就可以看到增加了Clear shell Window Ctrl+L,即清屏的快捷键为:Ctrl+L

转载于:https://www.cnblogs.com/xiaomingzaixian/p/6793219.html

你可能感兴趣的文章
sqlite rowid与主键
查看>>
vim 使用笔记
查看>>
Spring中Singleton模式的线程安全
查看>>
Spring整合- mongodb
查看>>
Activity 之继承学习 Fragment
查看>>
如何让你的scrapy爬虫不再被ban
查看>>
Python使用UUID库生成唯一ID
查看>>
WinSCP乱码解决
查看>>
部署在Tomcat 服务器中的web应用读取时间与系统时间不一致问题 【靠谱】
查看>>
<Tag> tld的配置
查看>>
datesheet你看懂了吗?
查看>>
第一课 redis安装配置
查看>>
ASP.NET开源博客QBlog开发者视频教程:生命周期Page_Load介绍及简洁传递参数的...
查看>>
项目成功必要条件
查看>>
ECharts简介及入门
查看>>
亿级Web系统搭建:单机到分布式集群
查看>>
第五十讲:tapestry乱码问题Invalid byte 3 of 3-byte
查看>>
linux系统学习笔记之Linux环境变量
查看>>
【开源项目】之照明智能开关
查看>>
DB2 全库查询赋权
查看>>