python IDEL 清屏
生活随笔
收集整理的這篇文章主要介紹了
python IDEL 清屏
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在Option 中增加clear shell window選項
1)將下述文件保存為ClearWindow.py,
并放置在?C:\\Users\\LIN\\AppData\\Local\\Programs\\Python\\Python37\\Lib\\idlelib'下
查看路徑的方法,import sys,? print(sys.path)
"""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) # add="+" doesn't workdef undo_event(self, event):text = self.texttext.mark_set("iomark2", "iomark")text.mark_set("insert2", "insert")self.editwin.undo.undo_event(event)# fix iomark and inserttext.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 ModifiedUndoDelegatortext = 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):# remove undo delegatorundo = self.editwin.undoself.editwin.per.removefilter(undo)# clear the window, but preserve current commandself.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 delegatorself.editwin.per.insertfilter(undo)?
?
?
2) 打開config-extensions.def 后在句末加上這樣幾句:
[ClearWindow]
enable=1
enable_editor=0
enable_shell=1
[ClearWindow_cfgBindings]
clear-window=<Control-Key-l>
然后保存退出就可以了。
打開python的idle,看看options是不是多了一個選項clear shell window ctrl+L
?
總結
以上是生活随笔為你收集整理的python IDEL 清屏的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mencoder 音视频格式转换
- 下一篇: Java使用ffmpeg和mencode