Thanks to visit codestin.com
Credit goes to github.com

Skip to content

"Run in interactive mode" and drag-n-drop support #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hiccup7 opened this issue May 3, 2016 · 11 comments
Closed

"Run in interactive mode" and drag-n-drop support #324

hiccup7 opened this issue May 3, 2016 · 11 comments

Comments

@hiccup7
Copy link

hiccup7 commented May 3, 2016

Here are some Windows registry features from Python(x,y) that I find useful, and I propose them for WinPython:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\WinPython-3.4.4.2\\python-3.4.4.amd64\\python.exe\" \"-i\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.File\shellex]

[HKEY_CLASSES_ROOT\Python.File\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\WinPython-3.4.4.2\\python-3.4.4.amd64\\python.exe\" \"-i\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex]

[HKEY_CLASSES_ROOT\Python.NoConFile\shellex\DropHandler]
@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

Before importing the above file into regedit, register WinPython with the OS. Also, edit the paths for your WinPython installation.

I am not sure if WinPython's register_python.bat already adds the DropHandler since this registry key has been on my PC before I first registered WinPython. It is really handy to drag an input file onto a Python script and then automatically access the input file name with sys.argv[1] in the Python script.

@stonebig
Copy link
Contributor

stonebig commented May 3, 2016

hum, I'm not expert in the dark art of Windows registery, and saw some people complaining of current WinPython registering feature ... It may take me a while to get a decision on this.

@hiccup7
Copy link
Author

hiccup7 commented May 3, 2016

These are just additional subkeys to the registry keys that WinPython already installs when it is "registered" with the OS. If the user chooses to keep WinPython "portable", they wouldn't be installed of course.

If WinPython includes these as standard features, I won't have to instruct every user at my company who uses WinPython. They would also make WinPython easier to use for schools.

@hiccup7
Copy link
Author

hiccup7 commented May 3, 2016

I should also clarify that my code above is example code for your experimentation. I expect WinPython's Python code for registering to be modified to include these new features using the installation path.

@stonebig stonebig added this to the 2016-03 Matplotlib 2.0 / PyQt5.6 / mingwpy update ... milestone May 3, 2016
@stonebig
Copy link
Contributor

stonebig commented May 4, 2016

hum, now I read what @PierreRaybaut wrote: https://github.com/winpython/winpython/blob/master/winpython/associate.py

I don't understand what I see, and I understand even less your patch with things like@="{60254CA5-953B-11CF-8C96-00AA00B8708C}"

passing by, I remember there was another request on the subject: #28

@hiccup7
Copy link
Author

hiccup7 commented May 5, 2016

With your tip to look at associate.py, I see the DropHandler is already included in WinPython. Therefore, I withdraw that part of my request.

For WinPython users who would like to learn how to use this great DropHandler feature, here is some explanation:
http://stackoverflow.com/questions/142844/drag-and-drop-onto-python-script-in-windows-explorer

My remaining request to support "Run in interactive mode" can be tested with the following file. Maybe name it "RunInInteractiveMode.reg" so the file will be associated by Windows with the regedit.exe application.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.File\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\WinPython-3.4.4.2\\python-3.4.4.amd64\\python.exe\" \"-i\" \"%1\" %*"

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Run in interactive mode]
@=""

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Run in interactive mode\command]
@="\"C:\\Program Files\\WinPython-3.4.4.2\\python-3.4.4.amd64\\python.exe\" \"-i\" \"%1\" %*"

To understand how associate.py works, it may be helpful to view its output in the Windows registry. Run regedit.exe and view the following keys, which are like folders for parameters:
HKEY_CLASSES_ROOT\Python.File
HKEY_CLASSES_ROOT\Python.CompiledFile
HKEY_CLASSES_ROOT\Python.NoConFile
Navigate through all the subkeys of these keys by double-clicking the mouse cursor on them.

Hopefully, this sheds some light on the dark art of the Windows Registry (database).

@hiccup7
Copy link
Author

hiccup7 commented May 5, 2016

Request #28 makes sense for Python(x,y), where only one Python version exists on a PC. WinPython supports multiple Python versions/environments installed, and request #28 would break this.

Registering one WinPython version with the OS only associates .py, .pyc, .pyo and .pyw extensions with handler applications with a particular WinPython version. "WinPython Command Prompt.exe" is used to modify the path and add environment variables for one cmd shell process. If the control panel changed the environment variables as suggested in #28, "WinPython Command Prompt.exe" for a second WinPython version wouldn't work. Pierre designed WinPython very well.

@stonebig
Copy link
Contributor

stonebig commented May 5, 2016

Indeed. I stiil don't know if and how I should patch the existing associate.py. Watching "the phantom menace" didn't help yesterday.

@hiccup7
Copy link
Author

hiccup7 commented May 6, 2016

I use the drag-n-drop feature dozens of times a day, while I use "Run in interactive mode" rarely. I now understand WinPython already has the first feature, and the second feature is not a high enough priority for me to reverse-engineer associate.py right now. Therefore, I am willing to let this issue go.

The registry modifications I suggested just add another right-click application association with .py, .pyc, .pyo and .pyw extensions in Windows Explorer. I feel clear that this is in the spirit of WinPython's model of optionally registering one Python version, while not breaking other Python versions/environments. I think the feature would be most useful for schools.

Since this modification is proving difficult for you, I suggest removing this issue from the next release milestone and tagging it with "help wanted". This gives an opportunity to contribute for some kind soul who wants to practice at Python and learn about the Windows registry.

@stonebig stonebig removed this from the 2016-03 Bokeh 0.12 / PyQt5.6 / mingwpy update ... milestone May 6, 2016
@stonebig
Copy link
Contributor

historic WinPython registration is back in Winpython-2022-04, after removing what frightens me: the "activeX" thing.

I don't know if anything more and usefull si possible

@stonebig
Copy link
Contributor

stonebig commented May 4, 2025

The winpython/associate.py has been totally revised this 2025-02 cycle, to make it readable..

Is there still need to add something somewhere there in 2025 ?
https://github.com/winpython/winpython/blob/master/winpython/associate.py#L124

@stonebig stonebig added this to the 2025-03 PEP 751 / AI local milestone May 10, 2025
@stonebig
Copy link
Contributor

Drag & drop support is cautiously re-,introduced this 2025-03 cycle, if anti-viruses do tolerate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants