生活随笔
收集整理的這篇文章主要介紹了
Python IDLE(shell清屏配置方法)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
具體操作如下:
1.復制下面代碼:
"""Clear Window Extension
Version: 0.2Author: Roger D. Serwyroger.serwy@gmail.comDate: 2009-06-14It 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
= editwinself
.text
= self
.editwin
.textself
.text
.bind
("<<clear-window>>", self
.clear_window2
)self
.text
.bind
("<<undo>>", self
.undo_event
) def undo_event(self
, event
):text
= self
.texttext
.mark_set
("iomark2", "iomark")text
.mark_set
("insert2", "insert")self
.editwin
.undo
.undo_event
(event
)text
.mark_set
("iomark", "iomark2")text
.mark_set
("insert", "insert2")text
.mark_unset
("iomark2")text
.mark_unset
("insert2")def clear_window2(self
, event
): text
= self
.texttext
.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
):undo
= self
.editwin
.undoself
.editwin
.per
.removefilter
(undo
)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
()self
.editwin
.per
.insertfilter
(undo
)
2.新建一個ClearWindow.py文件,將上面的代碼保存到到這個文件中。
3.找到python的安裝路徑:
電腦找到IDLE(Python ),鼠標右鍵->屬性
之后進入我的電腦,按照上面的路徑,找到:
打開LIb:
打開idlelib:
將ClearWindow.py文件放進來
4.用記事本打開config-extensions.def:
在文件末尾加上:
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
關閉保存就行。
打開Python Shell,
Options下如果出現:Clear Shell Window Ctrl + L則配置成功
這時Shell清屏就可以用 Ctrl + L了
總結
以上是生活随笔為你收集整理的Python IDLE(shell清屏配置方法)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。