
看一下IDLE的源代码。尤其要注意EditorWindow.py中的“ smart_backspace_event”。IDLE
<Key-Backspace>在文本窗口小部件上绑定到此功能(通过
<<smart-backspace>>事件间接)。
您将需要的基本代码如下所示:
chars = console.get("insert linestart", "insert")# [Do some analysis on "chars" to detect >>> and prevent a backspace]if DO_BACKSPACE: console.delete("insert-1c", "insert")# "break" is important so that the Text widget's backspace handler doesn't get calledreturn "break"欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)