How to make IDLE the default editor for Python files

xdg

If I double click on a Python file on my Gnome Classic desktop, it is not opened in IDLE. How can I make IDLE the default editor for Python files?

  1. I have tried to delete all the other programs that were being opened.

  2. I have been looking through IDLE's properties.

  3. I have been looking through the program's properties as well.

When I run

xdg-mime query default text/x-python

I get the output

gedit.destkop

I do have IDLE installed, and I tried to right click the file and open with an application. IDLE was nowhere to be seen. But when I go to my applications, and go to programming, IDLE is there, clear as day.

Best Answer

You can easily associate the .py files with IDLE. You have to right click a python script, choose "Open with -> Other application", then choose IDLE from the list with the checkbox asking if it should be the default application ticked. I use XFCE, but Gnome's Nautilus should be similar.

enter image description here

Alternatively, there is a configuration file in your home directory which contains the list of default applications. You can access it on the following path:

~/.local/share/applications/mimeapps.list

You can extend it with the following line:

text/x-python=idle.desktop

where idle.desktop stands for the desktop file of the IDLE version you would like to use, for instance idle-python2.7.desktop or idle-python3.desktop based on the python version you have to use.

NOTE:

Be aware of the permissions of your scripts. If it has the executable permission, despite the default application, your system won't open it in IDLE, as it will try to execute it.

Related Question