简体   繁体   中英

Python in TextMate - run script in IDLE?

Is it possible for TextMate to run Python scripts in IDLE instead of internally or via Terminal?

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.

I've had a play on OSX, and I think I've got it working.

Open TextMate's 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"

Choose a keyboard shortcut, and put it in the box next to 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. (Or whatever python version you're using - /usr/bin/idle3.1 etc)

You could also use the -e flag instead of the -r flag, to edit your script in IDLE instead of running it.

截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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