Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 839
MachineElf Avatar asked Feb 08 '26 02:02

MachineElf


1 Answers

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.

screenshot

like image 179
Alex L Avatar answered Feb 09 '26 15:02

Alex L



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!