Python 实现清屏
使用Python的IDLE到某个程序节点时,需要清屏以提高清晰度.
但IDLE本身并没有这个功能,我们可以通过扩展来实现类似于Ctrl + L的清屏
资料来自于百度经验的 BinnLZeng
先制作一个python文件ClearWindow.py
#File Name:ClearWindow.py
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_window) def clear_window2(self, event):
# Alternative method
# work around the ModifiedUndoDelegator
text = self.text
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")
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)
然后,将该文件move至 {PYTHON_HOME}\Lib\idlelib中
修改config-extensions.def文件
在末尾添加
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
来解释下什么意思
enable=1
#1为真 意思就是启用这个扩展
enable_editor=0
#编辑器禁用这个扩展
enable_shell=1
#IDLE Shell启动扩展
clear-window=<Control-Key-l>
#设置快捷键为Ctrl + L
---------------------------分割线-----------------------
再打开IDLE
点击Options,可以看到我们的扩展被成功加载。
同样,我们可以按下Ctrl + L进行清屏操作。我们还可以通过clear-window=<Control-Key-l>修改快捷键,例如修改为ctrl + 3,则是clear-window=<Control-Key-3>
Python 实现清屏的更多相关文章
- 转:python idle 清屏问题的解决
http://www.cnblogs.com/maybego/p/3234055.html python idle 清屏问题的解决 在学习和使用python的过程中,少不了要与python idle打 ...
- python idle 清屏问题的解决
在学习和使用python的过程中,少不了要与python idle打交道.但使用python idle都会遇到一个常见而又懊恼的问题——要怎么清屏? 我在stackoverflow看到这样两种答案 ...
- python shell 清屏(window)
IDLE增加一个清屏的扩展ClearWindow就可以了(在Issue 6143: IDLE中可以看到这个扩展的说明) 安装使用的方法 1.下载ClearWindow.py(右击-目标另存为,格式为p ...
- Python IDLE清屏
在学习和使用Python的过程中,少不了要与Python IDLE打交道.但使用 Python IDLE 都会遇到一个常见而又懊恼的问题--要怎么清屏? 答案是为IDLE增加一个清屏的扩展ClearW ...
- python实现清屏
往常都是用os.system("cls")清屏,但是发现每次执行完这个命令后都会出现一个空白字符 尝试了一下午,网上也没解决的办法 最后: os.system("cls& ...
- Python IDLE 清屏工具
转载自:http://www.cnblogs.com/maybego/p/3234055.html 1.下载clearwindow.py(右击-目标另存为,直接点击会打开脚本内容). 2.拷贝c ...
- python添加清屏功能
创建文件ClearWindow添加内容 class ClearWindow: menudefs = [ ('options', [None, ('Clear Shell Window', '<& ...
- python中的清屏函数
一:cmd中python的清屏函数 import os os.system("cls") cmd中演示 1.在cmd中输入命令行: 2.执行后: 3.为什么会遗留一个0? 因为函数 ...
- python3.4学习笔记(三) idle 清屏扩展插件
python3.4学习笔记(三) idle 清屏扩展插件python idle 清屏问题的解决,使用python idle都会遇到一个常见而又懊恼的问题——要怎么清屏?在stackoverflow看到 ...
随机推荐
- elasticsearch-mapping字段重要属性
https://blog.csdn.net/gongpulin/article/details/78705205
- mui中confirm在苹果出现bug,confirm点击确定跳转页面再返回后,页面被遮罩盖住无法使用
项目中使用confirm mui.confirm('您还未抽奖,现在去抽奖吗?', function (res) { if (res.index === 1) { window.location.hr ...
- Best Practices for Assembly Loading
原文链接 This article discusses ways to avoid problems of type identity that can lead to InvalidCastExce ...
- selenium python 中浏览器操作
1.启用浏览器 browser = webdriver.Chrome() 谷歌浏览器 browser = webdriver.Firefox() ...
- 数据拆分之 垂直拆分 and 水平拆分
https://mp.weixin.qq.com/s?__biz=MzI1NDQ3MjQxNA==&mid=2247488833&idx=1&sn=4f5fe577521431 ...
- 【Redis】windows下redis服务的安装
下载地址: https://github.com/MicrosoftArchive/redis/releases Redis 支持 32 位和 64 位.这个需要根据你系统平台的实际情况选择,这里我们 ...
- leecode第二百三十六题(二叉树的最近公共祖先)
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
- .NET Core WEB API中接口参数的模型绑定的理解
在.NET Core WEB API中参数的模型绑定方式有以下表格中的几种: 微软官方文档说明地址:https://docs.microsoft.com/zh-cn/aspnet/core/web-a ...
- myeclipse连接mysql生成数据表时中文字符乱码或问号(解决方法)
出现这个问题有以下三步解决思路: 1. 检查myeclipse的编码格式 windows---->Preferences---->general---->Workspace,右侧窗口 ...
- SWPU新闻后台登录页面
最终效果图: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <ti ...