鱼C论坛

 找回密码
 立即注册
查看: 1627|回复: 6

[已解决]清屏

[复制链接]
发表于 2020-7-9 17:53:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
这样还是用不了ctrl+l,跟版本有关系?( 3.8版本的
f60c106345d2c4d599c8932040b2816.png 809916ef8d4c0c30280af87b054d726.png 0f45673537a594f4f1bf47efcb9320f.png
最佳答案
2020-7-9 17:54:07
python目录下的 lib\idlelib 的文件夹下 新建文件名为 ClearWindow.py 保存


  1. """

  2. Clear Window Extension
  3. Version: 0.2

  4. Author: Roger D. Serwy
  5.         roger.serwy@gmail.com

  6. Date: 2009-06-14

  7. It provides "Clear Shell Window" under "Options"
  8. with ability to undo.

  9. Add these lines to config-extensions.def

  10. [ClearWindow]
  11. enable=1
  12. enable_editor=0
  13. enable_shell=1
  14. [ClearWindow_cfgBindings]
  15. clear-window=<Control-Key-l>


  16. """


  17. class ClearWindow:
  18.     menudefs = [
  19.         ('options', [None,
  20.                      ('Clear Shell Window', '<<clear-window>>'),
  21.                      ]), ]

  22.     def __init__(self, editwin):
  23.         self.editwin = editwin
  24.         self.text = self.editwin.text
  25.         self.text.bind("<<clear-window>>", self.clear_window2)

  26.         self.text.bind("<<undo>>", self.undo_event)  # add="+" doesn't work

  27.     def undo_event(self, event):
  28.         text = self.text

  29.         text.mark_set("iomark2", "iomark")
  30.         text.mark_set("insert2", "insert")
  31.         self.editwin.undo.undo_event(event)

  32.         # fix iomark and insert
  33.         text.mark_set("iomark", "iomark2")
  34.         text.mark_set("insert", "insert2")
  35.         text.mark_unset("iomark2")
  36.         text.mark_unset("insert2")

  37.     def clear_window2(self, event):  # Alternative method
  38.         # work around the ModifiedUndoDelegator
  39.         text = self.text
  40.         text.undo_block_start()
  41.         text.mark_set("iomark2", "iomark")
  42.         text.mark_set("iomark", 1.0)
  43.         text.delete(1.0, "iomark2 linestart")
  44.         text.mark_set("iomark", "iomark2")
  45.         text.mark_unset("iomark2")
  46.         text.undo_block_stop()
  47.         if self.text.compare('insert', '<', 'iomark'):
  48.             self.text.mark_set('insert', 'end-1c')
  49.         self.editwin.set_line_and_column()

  50.     def clear_window(self, event):
  51.         # remove undo delegator
  52.         undo = self.editwin.undo
  53.         self.editwin.per.removefilter(undo)

  54.         # clear the window, but preserve current command
  55.         self.text.delete(1.0, "iomark linestart")
  56.         if self.text.compare('insert', '<', 'iomark'):
  57.             self.text.mark_set('insert', 'end-1c')
  58.         self.editwin.set_line_and_column()

  59.         # restore undo delegator
  60.         self.editwin.per.insertfilter(undo)
复制代码

python目录下的 lib\idlelib文件夹下,用记事本打开文件config-extensions.def,在文件最后添加一下代码:
  1. [ClearWindow]
  2. enable=1
  3. enable_editor=0
  4. enable_shell=1
  5. [ClearWindow_cfgBindings]
  6. clear-window=<Control-Key-l>
复制代码




本帖被以下淘专辑推荐:

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-7-9 17:54:07 | 显示全部楼层    本楼为最佳答案   
python目录下的 lib\idlelib 的文件夹下 新建文件名为 ClearWindow.py 保存


  1. """

  2. Clear Window Extension
  3. Version: 0.2

  4. Author: Roger D. Serwy
  5.         roger.serwy@gmail.com

  6. Date: 2009-06-14

  7. It provides "Clear Shell Window" under "Options"
  8. with ability to undo.

  9. Add these lines to config-extensions.def

  10. [ClearWindow]
  11. enable=1
  12. enable_editor=0
  13. enable_shell=1
  14. [ClearWindow_cfgBindings]
  15. clear-window=<Control-Key-l>


  16. """


  17. class ClearWindow:
  18.     menudefs = [
  19.         ('options', [None,
  20.                      ('Clear Shell Window', '<<clear-window>>'),
  21.                      ]), ]

  22.     def __init__(self, editwin):
  23.         self.editwin = editwin
  24.         self.text = self.editwin.text
  25.         self.text.bind("<<clear-window>>", self.clear_window2)

  26.         self.text.bind("<<undo>>", self.undo_event)  # add="+" doesn't work

  27.     def undo_event(self, event):
  28.         text = self.text

  29.         text.mark_set("iomark2", "iomark")
  30.         text.mark_set("insert2", "insert")
  31.         self.editwin.undo.undo_event(event)

  32.         # fix iomark and insert
  33.         text.mark_set("iomark", "iomark2")
  34.         text.mark_set("insert", "insert2")
  35.         text.mark_unset("iomark2")
  36.         text.mark_unset("insert2")

  37.     def clear_window2(self, event):  # Alternative method
  38.         # work around the ModifiedUndoDelegator
  39.         text = self.text
  40.         text.undo_block_start()
  41.         text.mark_set("iomark2", "iomark")
  42.         text.mark_set("iomark", 1.0)
  43.         text.delete(1.0, "iomark2 linestart")
  44.         text.mark_set("iomark", "iomark2")
  45.         text.mark_unset("iomark2")
  46.         text.undo_block_stop()
  47.         if self.text.compare('insert', '<', 'iomark'):
  48.             self.text.mark_set('insert', 'end-1c')
  49.         self.editwin.set_line_and_column()

  50.     def clear_window(self, event):
  51.         # remove undo delegator
  52.         undo = self.editwin.undo
  53.         self.editwin.per.removefilter(undo)

  54.         # clear the window, but preserve current command
  55.         self.text.delete(1.0, "iomark linestart")
  56.         if self.text.compare('insert', '<', 'iomark'):
  57.             self.text.mark_set('insert', 'end-1c')
  58.         self.editwin.set_line_and_column()

  59.         # restore undo delegator
  60.         self.editwin.per.insertfilter(undo)
复制代码

python目录下的 lib\idlelib文件夹下,用记事本打开文件config-extensions.def,在文件最后添加一下代码:
  1. [ClearWindow]
  2. enable=1
  3. enable_editor=0
  4. enable_shell=1
  5. [ClearWindow_cfgBindings]
  6. clear-window=<Control-Key-l>
复制代码




小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2020-7-9 18:00:24 | 显示全部楼层
Twilight6 发表于 2020-7-9 17:54
python目录下的 lib\idlelib 的文件夹下 新建文件名为 ClearWindow.py 保存

非常感谢!但不知道什么原因还是用不了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-7-9 18:04:51 | 显示全部楼层
编程小白艾雪儿 发表于 2020-7-9 18:00
非常感谢!但不知道什么原因还是用不了

不会呀,你重新按流程来一遍试试看,我刚刚测试可用了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-7-9 18:22:07 | 显示全部楼层
Twilight6 发表于 2020-7-9 18:04
不会呀,你重新按流程来一遍试试看,我刚刚测试可用了

感谢!解决啦!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-7-9 18:24:09 | 显示全部楼层
按步骤来就可以,如果关闭软件没反应可以重启电脑试试。
我猜可能是我的垃圾电脑反应有点慢hhh,重启了一下可以用了!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-7-9 19:32:31 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-29 07:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表