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

"""

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\Lib\idlelib下修改config-extensions.def ,在末尾添加如下内容:

[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>

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

Python IDLE配置清屏快捷键(Ctrl+L)的更多相关文章

  1. Python IDLE 增加清屏功能

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

  2. linux清除全屏快捷键(Ctrl+L)

    Linux用户基本上都习惯使用clear命令或Ctrl+L组合快捷键来清空终端屏幕.这样做其实并没有真正地清空屏幕,但当用鼠标向上滚时,你仍然能看到之前的命令操作留下来的输出.

  3. Python IDLE如何清屏

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

  4. python中的清屏函数

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

  5. PhpStorm 快捷键大全 PhpStorm 常用快捷键和配置+如何关闭快捷键ctrl+alt+方向键旋转屏幕

    如果映射的是eclipse的快捷键,又同时安装了英特尔的GPU软件,那么会有这个快捷键冲突 就是快速复制快捷键:ctrl+alt+方向键  会调用英特尔旋转屏幕,禁用掉即可 PhPStorm 是 Je ...

  6. [Mac Terminal] ___MAC终端清屏快捷键

    清全屏: command + K 清上一行命令:command +  L

  7. Python IDLE 代码高亮主题

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

  8. 【Python开发】【编程开发】各种系统的清屏操作命令

    mac os x terminal清屏快捷键 cammand+k linux系统清屏快捷键 ctrl+l linux系统命令行清屏命令 clear windows 命令行清屏命令 cls Matlab ...

  9. Python:IDLE清屏

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

随机推荐

  1. 剑指Offer面试题 二维数组中的查找

    题目链接:https://www.nowcoder.com/questionTerminal/abc3fe2ce8e146608e868a70efebf62e 题目大意: 略 分析: 对萌醒很开拓思维 ...

  2. golang项目练习

    一.记账系统 1.该软件能够记录收入.支出,并能够打印收支明细表 2. 代码 package main import ( . "fmt" ) func menu() string{ ...

  3. jsp学习(1)jsp请求过程和生命周期

    一.服务器处理jsp请求的过程: 以下步骤表明了 Web 服务器是如何使用JSP来创建网页的: 1.浏览器发送一个 HTTP 请求给服务器. 2.Web 服务器识别出这是一个对 JSP 网页的请求,并 ...

  4. git的安装(和远程仓库建立连接)

    安装完git 1.配置用户名和邮箱 $ git config --global user.name "My Name"  $ git config --global user.em ...

  5. vim主题颜色

    1.VIM主题 查看Vim示例当前的颜色主题 打开一个Vim窗口,输入命令:color或:colorscheme后回车查看当前的颜色主题. Vim实例中设置颜色主题 输入命令"colorsc ...

  6. Java 8 特性 —— 函数式接口

    函数式接口 概述:接口中只有一个抽象方法. 函数式接口,即适用于函数式编程场景的接口.而 Java 中的函数式编程体现就是 Lambda,所以函数式接口就是可以适用于 Lambda 使用的接口.只有确 ...

  7. JS学习笔记Day20

    一. 1.服务器和客户端 客户端 程序: 通过浏览器直接运行 服务器 程序: 通过安装某种服务器软件   程序才可以运行              apache   php文件             ...

  8. 【转】Redis学习笔记(五)如何用Redis实现分布式锁(2)—— 集群版

    原文地址:http://bridgeforyou.cn/2018/09/02/Redis-Dsitributed-Lock-2/ 单机版实现的局限性 在上一篇文章中,我们讨论了Redis分布式锁的实现 ...

  9. 六十、linux 编程—— I/O 多路复用 select

    60.1 介绍 60.2 例子 echo_tcp_server_select.c #include <netdb.h> #include <netinet/in.h> #inc ...

  10. centos7.4下的python3.6的安装

    1.系统环境 :centos 7.4 最小化安装 2.安装过程 yum install wget      安装下载工具 wget https://www.python.org/ftp/python/ ...