Sublime Forum

Run python scripts by just pressing a key on linux(xubuntu)

#1

On windows OS, this code saved as python_run.py in packages folder:

import sublime
import sublime_plugin
import subprocess
class PythonRunCommand(sublime_plugin.WindowCommand):
def run(self):
command = [‘cmd’,’/k’,r"C:\Python34\python.exe",sublime.active_window().active_view().file_name()]
subprocess.Popen(command)

key binding:
{
“keys”: “f2”],
“command”: “python_run”
}

The code above as it is only works on Windows, by just pressing F2, I can run any script, is it possible that the code above can be edited in such way that could function on Linux(Xubuntu)??

0 Likes

#2

why not just use the (Python) build system?

0 Likes

#3

What do you mean? I can run python code by open the terminal, typing ptyhon3 /path/path/code.py…

but i want the convenient and easy way of just pressing a key…

0 Likes

#4

Ctrl+B

0 Likes

#5

but doing that will allow me to input values??? I have tried that on widnows OS, and the code runs in the same window of SB3 and there is no way for inputting values

0 Likes

#6

No, the ST build system doesn’t support input



0 Likes