網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
實(shí)現(xiàn)步驟:
新建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_window2)
self.text.bind("<<undo>>", self.undo_event) # add="+" doesn't work
def undo_event(self, event):
text = self.text
text.mark_set("iomark2", "iomark")
text.mark_set("insert2", "insert")
self.editwin.undo.undo_event(event)
# fix iomark and insert
text.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 ModifiedUndoDelegator
text = self.text
text.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 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)
將ClearWindow.py復(fù)制到python安裝目錄下的Lib\idlelib目錄(比如我的是:D:\Softwares\Python\Python310\Lib\idlelib)
修改idlelib目錄下的config-extensions.def。修改之前最好先復(fù)制一份作為備份。
在文件末尾添加如下內(nèi)容:
[ClearWindow]
enable = True
enable_editor = False
enable_shell = True
[ClearWindow_cfgBindings]
clear-window = <Control-Key-l>
保存文件并關(guān)閉。
啟動(dòng)IDLE
點(diǎn)擊"Options",會(huì)發(fā)現(xiàn)多了一個(gè)選項(xiàng)“Clear Shell Window”。
隨便輸入一些指令
按快捷鍵Ctrl+L(或者鼠標(biāo)點(diǎn)擊“Options”,選擇“Clear Shell Window”。
再輸入指令,發(fā)現(xiàn)能正常使用。
原文鏈接:https://blog.csdn.net/username666/article/details/126756301
相關(guān)推薦
- 2022-12-13 Kotlin?coroutineContext源碼層深入分析_Android
- 2022-02-09 C語(yǔ)言指針用法總結(jié)_C 語(yǔ)言
- 2022-06-11 python中Event實(shí)現(xiàn)線程間同步介紹_python
- 2022-12-10 C++?Boost?Spirit精通教程_C 語(yǔ)言
- 2022-11-21 Python進(jìn)制轉(zhuǎn)換與反匯編實(shí)現(xiàn)流程介紹_python
- 2023-03-04 c++元編程模板函數(shù)重載匹配規(guī)則示例詳解_C 語(yǔ)言
- 2022-07-24 Git版本控制服務(wù)器詳解_其它綜合
- 2022-09-09 Go?http請(qǐng)求排隊(duì)處理實(shí)戰(zhàn)示例_Golang
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支