bumblebee166
Posts: 5
Joined: Tue Sep 15, 2015 1:17 pm

Starting Python script without startup choice

Thu Sep 17, 2015 7:18 pm

Hi,

I am trying to set up a set of python programs in a folder for my daughter to run. When i double click on them it pops up with Execute, Execute In Terminal, Open, Cancel. I want them to by default Execute, as they use pygame. Is there a way to make it so all .py files use the Execute option without another click?

Thanks

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: Starting Python script without startup choice

Thu Sep 17, 2015 7:58 pm

Open File Manager and navigate to the directory with the scripts. Right click on one of the files and select "Open with..."
When the "Choose Application" dialog box comes up click on the "Custom Command Line" tab.
Enter "python", or "python3", or "sudo python", etc in the command line text box depending on what you need. I haven't used pygame but if that's the way you start it at a command line use "pygame".
Put a check in "Set selected application as default action for this file type", then OK.

It should now run the script whenever you double click on it without asking any questions.

bumblebee166
Posts: 5
Joined: Tue Sep 15, 2015 1:17 pm

Re: Starting Python script without startup choice

Fri Sep 18, 2015 1:51 pm

Thanks. I actually did this and it did not stick, i.e. when I tried to open it again the settings were gone and it came back. The shortcut had been made in .local/share/applications/user... (not at machine now but path was something like that), and it seemed kosha enough but the file manager did not seem to be obeying it. Are there any reasons it would ignore these shortcut files?

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: Starting Python script without startup choice

Fri Sep 18, 2015 2:27 pm

You didn't say anything about a shortcut being involved, you wanted to be able to run a Python script just by clicking on a .py file in File Manager. What is the shortcut you've added, and how is it related to clicking on a .py file to execute it?

Return to “Advanced users”