This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Migrate IDLE context menu items to shell extension
Type: enhancement Stage: needs patch
Components: IDLE, Installation, Windows Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Shane Smith, paul.moore, steve.dower, terry.reedy, tim.golden, veky, zach.ware
Priority: low Keywords:

Created on 2016-07-24 03:59 by steve.dower, last changed 2022-04-11 14:58 by admin.

Messages (10)
msg271123 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-07-24 03:59
Currently (on Windows) we register a set of subcommands in order to display an expanding list of versions of IDLE when users right-click a .py file.

With issue27469, a proper shell extension was added, which means we can now use IContextMenu to implement the menu rather than fixed registry keys. This would allow us to detect all installed versions of IDLE and present them without having to register new keys (i.e. forwards and backwards compatibility).
msg271124 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-07-24 04:00
Another idea: we can also provide extra ("extended") commands when the user holds Shift and right-clicks a file. We could use this to add items to do "-r file.py" with IDLE, which would run the file with IDLE and leave the Shell open.
msg284922 - (view) Author: Shane (Shane Smith) Date: 2017-01-07 15:49
Would it be possible to allow the user to select whether they'd prefer a nested or flat context menu at install?  I believe it went to nested as a result of issue23546.

Unless there are a large number of installations (arbitrarily... perhaps 4 or more), the nested menu is a pain for a user like me who wants to open .py files in IDLE more than any other action.  (If I may quote the fifth line of The Zen of Python... "Flat is better than nested.")  With a little research, it was a fairly easy registry hack to de-nest the context menu.

Still, a lot of people don't like to mess around in the registry, and user choice is usually a good thing.  Thoughts?
msg285190 - (view) Author: Vedran Čačić (veky) * Date: 2017-01-11 06:29
Even worse: I had both 3.5 and 3.6 installed, and then uninstalled 3.5 when 3.6 was final (I suppose I'm not the only one). Now I have the nested menu with only one item, Open with IDLE 3.6. :-\
msg285223 - (view) Author: Shane (Shane Smith) Date: 2017-01-11 13:38
Hi Vedran, that seems to now be the default behavior, regardless of previous installs (my 3.6 was a clean install, and it's still nested).  Kind of a pain if you want to edit with IDLE frequently.

While we wait for a more integrated solution, the hackish way to restore desired behavior is to run a .bat file containing:

REG DELETE "HKEY_CLASSES_ROOT\Python.File\shell\editwithidle"

Then run a .reg file (also just a text file with altered extension so windows knows what to do with it) with:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE 3.6\command]
@="\"C:\\Program Files\\Python36\\pythonw.exe\" -m idlelib \"%L\" %*"
msg285237 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-01-11 16:40
More user choice here is actually an incredibly huge burden. Managing file associations across a range of versions, many of which can no longer be updated, is hard enough without offering options. Not to mention the extra user interface required.

Personally, I'd rather the options be third party installers or tools. There's nothing stopping someone making an idle "installer" that sets up context menus and default actions however it likes. It would probably break uninstall/upgrade scenarios for the core Python install, but at least it's not a burden on our (very few) volunteers to diagnose, fix and prevent.

If or when the shell extension takes over the context menu (currently blocked on someone volunteering to do the implementation and testing), it may be possible to have registry keys to change the behavior. But I wouldn't count on it being highly configurable - that's not the aim of the main distro.
msg285242 - (view) Author: Shane (Shane Smith) Date: 2017-01-11 16:53
I'm fine with a single implementation, so long as the implementation is what's best for the majority of users.  Not my intent to increase the burden of work.

So, let me ask the question alluded to in my first post: when is a nested menu actually desirable?  I would argue that the vast majority of users have one or two versions of Python installed at any given time.  And for that number, a flat menu is certainly preferred.

The X.Y version numbering in the context menu introduced as a result of issue23546 solves said issue.  I'm merely suggesting de-nesting the menu.
msg285257 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-01-11 18:37
The last time I saw collected data on usage (based on Visual Studio users), there was no clear majority of "number of interpreter versions", but 3 was the most common (2 and 4 were roughly equal, 5 and 6 were more popular than 1).

The nesting also makes it considerably simpler for the installer to handle, since there are totally independent components contributing to the file association. This is very difficult to achieve in a reliable way (wrt upgrades/downgrades/uninstalls/repairs/order-of-install/etc.), and having the context menu here is the best balance of reliability, usability and ease of implementation.

Using the shell extension to generate the menu would also work well, as that is part of the launcher and independent of any particular Python installer. It can also automatically un-nest the menu when it's going to be short enough, or show the latest version at the top and nest all others. Ultimately though, implementing that requires somebody's time, and until somebody is motivated enough to do the work, it won't happen.

So your suggestion is valid, it just isn't motivating enough for me to make the change. That doesn't mean someone else can't do it, and from a personal level I will oppose a straight un-nesting (as I'm one of the outliers who has 20+ copies of Python installed on my machines :) ), but I'm totally in favour of a well implemented shell extension to make it more complete and easier to use.
msg285271 - (view) Author: Shane (Shane Smith) Date: 2017-01-11 20:56
Since you're a developer, I'm sure you need a lot of versions installed so you can check for backwards combatibility (spelling intentional).  But until recently, only the most recent IDLE was in the context menu, so I'm guessing your workflow for that checking doesn't depend on the context menu.  (I liked the old way, BTW, but I can see how someone might not).

But so long as you're doing it the current way, it remains easily hacked back to the way I like it, so I don't have a whole lot to complain about.  Carry on, good sir.
msg370854 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-06-06 22:07
Steve, is this out of date or still something that could be done in the code we control?  Would you review and possibly merge a patch is submitted? (I don't know what 'shell extension' means.)
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71790
2020-06-06 23:39:26terry.reedysetassignee: terry.reedy ->
2020-06-06 22:08:02terry.reedysetassignee: terry.reedy
components: + Installation
2020-06-06 22:07:44terry.reedysetmessages: + msg370854
versions: + Python 3.10, - Python 3.6
2017-01-11 20:56:48Shane Smithsetmessages: + msg285271
2017-01-11 18:37:54steve.dowersetmessages: + msg285257
2017-01-11 16:53:09Shane Smithsetmessages: + msg285242
2017-01-11 16:40:37steve.dowersetmessages: + msg285237
2017-01-11 13:38:22Shane Smithsetmessages: + msg285223
2017-01-11 06:29:03vekysetnosy: + veky
messages: + msg285190
2017-01-08 13:06:48terry.reedysetassignee: terry.reedy -> (no value)
2017-01-07 15:49:30Shane Smithsetnosy: + Shane Smith
messages: + msg284922
2016-07-24 04:00:11steve.dowersetmessages: + msg271124
2016-07-24 03:59:59steve.dowercreate