idle清屏
Posted gkl123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了idle清屏相关的知识,希望对你有一定的参考价值。
-
下载一个叫ClearWindow.py 的扩展文件,代码如下(将以下代码命名为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)
? -
打开python的安装目录(默认在C:UsersAdministratorAppDataLocalProgramsPythonPython36-32Libidlelib,如果实在是找不到安装的地方,在开始菜单中打开idle,选择交互模式,输入代码 import os print(os.getcwd()),输出的即为python的安装目录),找到lib目录下的idlelib 目录,然后把上面的代码拷贝到idlelib目录下。找到config-extensions.def 配置文件打开,在文件末尾加入以下配置即完成idle清屏插件的安装,清屏快捷键 Ctrl + L
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
以上是关于idle清屏的主要内容,如果未能解决你的问题,请参考以下文章