1、将下面文件复制到命名为ClearWindow.py的文件下,移动到 …Python\Python36-32\Lib\idlelib下。
###################################################################################
""" Clear Window Extension
Version: 0.2 Author: Roger D. Serwy
roger.serwy@gmail.com Date: 2009-06-14 It provides "Clear Shell Window" under "Options"
with ability to undo. Add these lines to config-extensions.def [ClearWindow]
enable=1
enable_editor=0
enable_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)
###################################################################################
2、接下来就是要在 …Python\Python36-32\Lib\idlelib文件夹下,用记事本打开文件config-extensions.def,在文件最后添加一下代码:
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>

Python-IDLE实现清屏的更多相关文章

  1. Python IDLE配置清屏快捷键(Ctrl+L)

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

  2. Python IDLE 增加清屏功能

    (Python2,Python3 通用) 保存如下代码到 ClearWindow.py """ Clear Window Extension Version: 0.2 A ...

  3. python中的清屏函数

    一:cmd中python的清屏函数 import os os.system("cls") cmd中演示 1.在cmd中输入命令行: 2.执行后: 3.为什么会遗留一个0? 因为函数 ...

  4. Python IDLE如何清屏

    金gordon 原文 IDLE如何清屏 在学习和使用python的过程中,少不了要与Python IDLE打交道.但使用 Python IDLE 都会遇到一个常见而又懊恼的问题——要怎么清屏? 答案是 ...

  5. Python IDLE 代码高亮主题

    Python IDLE 代码高亮主题 使用方法: 打开C盘我的 C:\Documents and Settings\你的用户名.idlerc文件夹 里面会有一个 config-highlight.cf ...

  6. Python:IDLE清屏

    清屏很简单,为IDLE增加一个清屏的扩展ClearWindow即可. 首先下载clearwindow.py(点击可直接下载,不能下载的可以右键保存,格式为py结尾), 将这个文件放到Python安装目 ...

  7. python idle 清屏问题的解决

    在学习和使用python的过程中,少不了要与python idle打交道.但使用python idle都会遇到一个常见而又懊恼的问题——要怎么清屏?   我在stackoverflow看到这样两种答案 ...

  8. 转:python idle 清屏问题的解决

    http://www.cnblogs.com/maybego/p/3234055.html python idle 清屏问题的解决 在学习和使用python的过程中,少不了要与python idle打 ...

  9. Python IDLE清屏

    在学习和使用Python的过程中,少不了要与Python IDLE打交道.但使用 Python IDLE 都会遇到一个常见而又懊恼的问题--要怎么清屏? 答案是为IDLE增加一个清屏的扩展ClearW ...

  10. Python 实现清屏

    使用Python的IDLE到某个程序节点时,需要清屏以提高清晰度. 但IDLE本身并没有这个功能,我们可以通过扩展来实现类似于Ctrl + L的清屏 资料来自于百度经验的 BinnLZeng 先制作一 ...

随机推荐

  1. C语言之栈区、堆区

    一 局部变量存放在栈区中,函数调用结束后释放内存空间. #include "stdio.h"; #include "stdlib.h"; int *getNum ...

  2. sizeof 4字节对齐

    #include <iostream> #include<assert.h> using namespace std; typedef struct sys{ char a; ...

  3. Python爬虫项目--爬取某宝男装信息

    本次爬取用到的知识点有: 1. selenium 2. pymysql 3  pyquery 正文 1. 分析目标网站 1. 打开某宝首页, 输入"男装"后点击"搜索&q ...

  4. 32-改变eclipse默认的Tomcat部署路径

    转载:https://www.cnblogs.com/helf/p/9433588.html eclipse中默认的项目部署路径是在项目的路径,不像myeclipse那样部署后项目在Tomcat的安装 ...

  5. mysql 复制原理与实践

    复制功能是将一个mysql数据库上的数据复到一个或多个mysql从数据库上. 复制的原理:在主服务器上执行的所有DDL和DML语句都会被记录到二进制日志中,这些日志由连接到它的从服务器获取,并复制到从 ...

  6. pycharm 出现Process finished with exit code 0 或 Process finished with exit code -1

    Process finished with exit code 0 意味着你的程序正常执行完毕并退出. 可以科普一下exit code,在大部分编程语言中都适用: exit code 0 表示程序执行 ...

  7. pyton random 模块

    import random print(random.random())#(0,1)----float 大于0且小于1之间的小数 print(random.randint(1,3)) #[1,3] 大 ...

  8. 浏览器与服务器交互原理以及用java模拟浏览器操作v

    浏览器应用服务器JavaPHPApache * 1,在HTTP的WEB应用中, 应用客户端和服务器之间的状态是通过Session来维持的, 而Session的本质就是Cookie, * 简单的讲,当浏 ...

  9. 继承 (js原型链)

    原型链是实现继承的主要方法.基本思想:利用原型让一个引用类型继承另一个引用类型的属性和方法. 1.构造函数.原型.实例的关系: 每个构造函数都有原型属性(Prototype),指向一个原型对象(函数创 ...

  10. BZOJ1217或洛谷2279 [HNOI2003]消防局的设立

    BZOJ原题链接 洛谷原题链接 该题有两种做法,树形\(DP\)和贪心. 先讲贪心. 先将所有点按深度从大到小排序,然后从大到小依次取出点,若已经被覆盖则跳过,否则就在它的祖父点建立消防站. 考虑如何 ...