idle清屏
阿新 • • 發佈:2018-11-05
-
下載一個叫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:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Lib\idlelib,如果實在是找不到安裝的地方,在開始選單中開啟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>