简体   繁体   English

TextMate中的Python - 在IDLE中运行脚本?

[英]Python in TextMate - run script in IDLE?

Is it possible for TextMate to run Python scripts in IDLE instead of internally or via Terminal? TextMate是否可以在IDLE中而不是在内部或通过终端运行Python脚本?

Rather than just use the Python build that comes with IDLE installation I want the shell window to actually launch so I can type in the interactive session. 我不想仅使用IDLE安装附带的Python构建,而是希望shell窗口实际启动,这样我就可以输入交互式会话。

I've had a play on OSX, and I think I've got it working. 我在OSX上玩过,我想我已经开始工作了。

Open TextMate's Bundle Editor ( Bundles -> Bundle Editor -> Show Bundle Editor ) 打开TextMate的Bundle Editor( Bundles - > Bundle Editor - > Show Bundle Editor

On the left hand side: Expand Python , then duplicate your "Run Script" command (bottom corner, second-left button [++]), and name it "Run Script in IDLE" 在左侧:展开Python ,然后复制“运行脚本”命令(底角,第二个左键[++]),并将其命名为“在IDLE中运行脚本”

Choose a keyboard shortcut, and put it in the box next to Activation : Key Equivalent 选择键盘快捷键,并将其放在Activation :Key Equivalent旁边的框中

Replace the following line: 替换以下行:

TextMate::Executor.run(ENV["TM_PYTHON"] || "python", "-u", ENV["TM_FILEPATH"]) do |str, type|

with

TextMate::Executor.run("/usr/bin/idle2.7", "-r", ENV["TM_FILEPATH"]) do |str, type|

This supplies your filepath as an argument to idle, as if you ran /usr/bin/idle2.7 -r /path/to/script.py directly. 这会将您的文件路径作为参数提供给空闲,就像您直接运行/usr/bin/idle2.7 -r /path/to/script.py (Or whatever python version you're using - /usr/bin/idle3.1 etc) (或者你正在使用的任何python版本 - /usr/bin/idle3.1等)

You could also use the -e flag instead of the -r flag, to edit your script in IDLE instead of running it. 您也可以使用-e标志而不是-r标志来编辑IDLE中的脚本而不是运行它。

截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM