If the flag always uses the selected program to open this type , the flag is grayed out , uncheck it:
- Open regedit Go to
- HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts
- Find the .py extension among the list
- Delete UserChoice (folder)
Then you can go to: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python XX and select IDLE ...
or
browse to C:\...\PythonXX\Lib\idlelib\idle.bat and select this.
---- If you are upgrading from a previous version of Python ----
I just upgraded from Python 3.4 to Python 3.5, and it was a nightmare setting IDLE as my default program. I spent so much time. I finally got to the place where I no longer need to right-click and select IDLE. Instead, I just click on the .py file and it opens IDLE by default ... and it has a legit-looking Python icon (and not an ugly .bat icon).
I publish this, so basically I will remember how I did it!
At this point, you can click on the python file (file with the extension .py) and it will open using the idle idle.bat program. I read that sometimes this does not work for some people.
But now the .py file icon looks like a .bat program icon. This seems like crap, so I took the following steps to associate the Python icon with .py files.
- Run> run> regedit (run registry editor)
- In the registry editor, go to:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice and pay attention to Progid (Applications \ idle.bat in my example). 
- If UserChoice does not exist, go to
HKEY_CLASSES_ROOT\.py and note the value (default) (for example: py_auto_file). 
I did not know what to change, so I changed BOTH .
Go to: HKEY_CLASSES_ROOT\Applications\idle.bat . The "DefaultIcon" folder does not exist, so I right-click idle.bat and select New> Key and name it "DefaultIcon". For the default data, I put C:\Python35\Lib\idlelib\Icons\idle.ico to reference the .ico image that is in the IDLE icon folder. 
Go to: HKEY_CLASSES_ROOT\py_auto_file and follow the same steps as step 12.1. 
- Reboot the computer.
Final result
After all these steps, I can now double-click the .py file on Windows and it will run the file in Python IDLE.
source share