在Python IDLE中实现清屏
来源:互联网 发布:淘宝一天最多几个好评 编辑:程序博客网 时间:2024/05/18 22:46
屏幕东西太多,需要清屏,在windows的窗口清屏命令是cls,在Python IDLE中的快捷键是Ctrl+L
不过这个快捷键默认是没有的,需要进行一些操作
一、将下面的代码复制保存到新建的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)
二、将这个文件放在Python X\Lib\idlelib目录下(X为你的python版本)
三、然后在这个目录下找到config-extensions.def这个文件(idle扩展的配置文件),以记事本的方式打开它
四、打开config-extensions.def 后在句末加上如下代码
[ClearWindow]enable=1enable_editor=0enable_shell=1[ClearWindow_cfgBindings]clear-window=<Control-Key-l>
五、然后保存退出就可以了。
打开python的idle,看看options是不是多了一个选项clear shell window ctrl+L
这时ctrl+l就可以实现清屏了
阅读全文
0 0
- 在Python IDLE中实现清屏
- python IDLE中实现清屏
- Python-IDLE实现清屏
- Python IDLE 如何实现清屏
- Python Shell 中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清屏
- 算法导论快速排序实现
- Ajax请求获取的List在前台遍历的方法
- Top 10 Things I Know for Sure-深信不疑的十大哲理
- zigbee的睡眠定时器
- Java日期加一天或加一月或加一年
- 在Python IDLE中实现清屏
- JAVA8学习笔记-Function
- 关于<c:if>没有<c:else>解决方案
- 分享一个仿微信多选图cordova插件(相册内带相机功能)
- 二分查找法
- SSD卡驱动中trim命令的实现原理
- Scrollview嵌套Recyclerview出现的显示不全 不显示问题的解决方法
- 数据库个人总结
- 神经网络入门之Logistic回归(分类问题)