4

I have followed the instructions in this thread: How do I set IDLE as the default editor for Python scripts?, but it hasn't resulted in the option to open in IDLE being shown.

So I used the 'Find applications online' option in the 'Open with...' menu and installed SPE (Stanli's Python Editor) at it's recommendation, but the option to open .py files with that also isn't in the menu.

Does anyone have any suggestions? I'm running ubuntu 13.10 and am trying to use Python 3.3.

Thanks in advance.

Screenshots:

Option 1:

mimeapps.list

open with options

Option 2:

idle.desktop

more open with options

3 Answers3

5

I had the same problem. This how I solved it:

  1. Uninstall idle from where you installed it.
  2. Install IDLE (using Python-3.3) from the Ubuntu Software Center. (It didn't work when I installed from Synaptic)
  3. Enter in terminal: gksudo gedit /usr/share/applications/idle-python3.3.desktop
  4. Edit file so it looks like this (exactly):
[Desktop Entry]
Name=IDLE (using Python-3.3)
Comment=Integrated Development Environment for Python (using Python-3.3)
Exec=/usr/bin/idle-python3.3 %F
Icon=/usr/share/pixmaps/python3.3.xpm
Terminal=false
Type=Application
Categories=Application;Development;
MimeType=text/x-python;
StartupNotify=true

Then it was visible in the menu for me.

1

OPTION 1:

Edit your $HOME/.local/share/applications/mimeapps.list if you want such association to be only applied for your user.

Add the following lines:

[Default Applications]
text/x-python=idle.desktop

[Added Associations]
text/x-python=idle.desktop;

Note, if you want the .py association for all users the file to modify is (using sudo):

/usr/share/applications/defaults.list

OPTION 2:

To set up IDLE as the default editor you'll have to make the idle.desktop file visible in the "Open with" list. To to so edit this file using sudo:

sudo gedit /usr/share/applications/idle.desktop

And replace its content by the following lines:

[Desktop Entry]
Name=IDLE
Comment=Integrated Development Environment for Python
Exec=/usr/bin/idle %F
Icon=/usr/share/pixmaps/idle.xpm
Terminal=false
Type=Application
Categories=Application;Development;
MimeType=text/x-python;
StartupNotify=true

Needless to restart your session or computer, to set the default application for the python type, locate a file of that type (*.py) in the file manager, right-click it, and select Properties.

Click the "Open With" tab and select the application you want to use for that file type.

Use the Set as default button to make the application the default application.

enter image description here

From now, clicking on a python file should open your preferred editor.

1

Thank you Sylvain Pineau for your contribution.

But I just want to add something to your answer for those who have installed python3 and use IDLE3. None of the two options there worked, but then I figured out that maybe it could work if I modify it, because I have python3.

Here we go, for python3:

To set up IDLE as the default editor you'll have to make the idle.desktop file visible in the "Open with" list. To to so edit this file using sudo:

sudo gedit /usr/share/applications/idle3.desktop

And replace its content by the following lines:

[Desktop Entry]
Name=IDLE 3
Comment=Integrated DeveLopment Environment for Python3
Exec=/usr/bin/idle3 %F
Icon=/usr/share/pixmaps/idle3.xpm
Terminal=false
Type=Application
Categories=Application;Development;
MimeType=text/x-python3;
StartupNotify=true

Needless to restart your session or computer, to set the default application for the python type, locate a file of that type (*.py) in the file manager, right-click it, and select Properties.

Click the "Open With" tab and select the application you want to use for that file type.

Use the Set as default button to make the application the default application.

Thank you so much!