【发布时间】:2013-06-25 13:58:46
【问题描述】:
IDLE 并没有什么问题,但是在功能和易用性方面还差很多。
我想让 Sublime-text2 的行为方式与 IDLE 一样。右边有一个窗口,里面有我的代码,左边有一个交互式 python 控制台。我可以通过在编辑器中安装包控制和 sublimerepl 来做到这一点。接下来我想绑定 F5 以在 sublimerepl 控制台中运行我的脚本。我找到了一个线程并关注了these instructions。不幸的是,我收到了this error。我认为错误是由于 Windows 机器造成的,因为 linux 工作正常。
F5绑定插件代码:
import sublime, sublime_plugin
class PydevCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command('set_layout', {"cols":[0.0, 1.0], "rows":[0.0, 0.5, 1.0], "cells":[[0, 0, 1, 1], [0, 1, 1, 2]]})
self.window.run_command('repl_open',{"type": "subprocess",
"encoding": "utf8",
"cmd": ["python2.7", "-i", "-u", "$file"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python2.7"
})
self.window.run_command('move_to_group', { "group": 1 })
如何修改插件代码,以便按 F5 键在 Windows 上按预期工作?
【问题讨论】:
-
您是否记得在路径中使用单引号或使用双斜杠?
-
都不行,我也尝试了
"Packages\\Python\\Python.tmLanguage"和'Packages\Python\Python.tmLanguage'的完整路径。
标签: sublimetext2 sublimetext sublimerepl