Python-IDLE实现清屏
来源:互联网 发布:彩先知软件 编辑:程序博客网 时间:2024/05/27 06:51
提要:
在百度上查了一下关于Python自带IDLE清屏的方法,在这里记录一下,也算分享一下吧。
只需要几个简单的步骤就可以实现IDLE清屏。
1、点击下载 ClearWindow.py
2、复制 ClearWindow.py文件到安装路径 …\PYTHON\Lib\idlelib下,例如:我的安装目录是D:\PYTHON\Lib\idlelib,将其复制到idlelib文件夹。
或许下载有些麻烦,这样吧,新建一个.py文件,把它放到上面的文件夹里面,名字就叫ClearWindow.py吧,因为现在我还不知到这个名字跟后面要添加的一小段代码有什么密切的关联。
然后内容就是下面的了:(开启你的复制粘贴技能吧)
"""Clear Window ExtensionVersion: 0.2Author: Roger D. Serwy roger.serwy@gmail.comDate: 2009-06-14It provides "Clear 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 Shell 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 = self.text text.mark_set("iomark2", "iomark") text.mark_set("insert2", "insert") self.editwin.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.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_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.text.mark_set('insert', 'end-1c') self.editwin.set_line_and_column() # restore undo delegator self.editwin.per.insertfilter(undo)
3、好了,接下来就是要在idle文件夹下,用记事本打开文件config-extensions.def,在文件最后添加一下代码:
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
完成后如下:
4、上面弄完之后,保存文件然后退出。接着检查一下有没有成功。
打开IDLE,可在options一栏下看到添加了一项clear选项,如下:
5、使用快捷键 ctrl+L 即可实现清屏。
ps:在找到这个方法过程中发现有另一种IDLEX,属于IDLE的加强版,其中添加了许多人性化的便捷功能,如有需要可以自行查找,等哪天我需要用的时候再用那个版本,我信奉的原则是:当前的够用就行。
阅读全文
0 0
- Python-IDLE实现清屏
- Python IDLE 如何实现清屏
- python IDLE中实现清屏
- 在Python IDLE中实现清屏
- [python]Python IDLE清屏
- python idle 清屏
- Python IDLE 清屏问题
- Python IDLE 清屏问题
- python idle 清屏
- Python IDLE 清屏
- python IDLE清屏
- Python IDLE 清屏
- Python IDLE 清屏插件
- Python IDLE 清屏
- python IDLE怎么清屏
- Python的idle清屏
- Python IDLE清屏
- Python idle 清屏问题解决
- springmvc的编码问题
- 自由编译配置软件autoconf
- Hbase shell
- hadoop完全分布环境搭建
- browserify出现ParseError: Unexpected character '�'
- Python-IDLE实现清屏
- [Leetcode]Dynamic Programming-note
- shell if语句和test命令
- 阿里云|REDIS 开启多个端口
- JavaScript实现图片轮播图
- 初入Tensorflow一览(1)
- 9.10NOIP模拟赛
- linux中磁盘的挂载
- 贪婪算法之找零钱