Sublime Forum

Problems with Python Turtle

#1

So I’m using sublime for school, and I’m coding with pythons built in line drawing library, turtle. I use a method to draw my lines, then have an input statement to pause. I currently have it set to just have the user press enter to continue. When it gets to this part and I press enter, the turtle window crashes and sublime freezes. If I run the same file in pycharm, it works.

I hope I explained that the best I could, but it seems that sublime is causing some hangup between the input statement and drawing the next shape.

0 Likes

#2

The ST build system does not support user input, but you can change it to use a terminal. Install PackageResourceViewer and open the file Python/Python.sublime-build and change it to the following. Then you can just press ctrl+shift+b and select “Python - Terminal” to run it in a terminal.

{
    "shell_cmd": "python -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "working_dir": "$file_path",
    "quiet": true,

    "variants":
    [
        {
            "name": "Terminal",
            "windows": {
                "shell_cmd": "start \"$file_name\" cmd /c \"python $file_name & pause\"",
            },
            "linux": {
                "shell_cmd": "xterm -T \"$file_name\" -e \"python $file_name; echo Press enter to exit... & read\"",
            }
        },
        {
            "name": "Syntax Check",
            "shell_cmd": "python -m py_compile \"${file}\"",
        }
    ]
}


2 Likes

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