当前位置: 动力学知识库 > 问答 > 编程问答 >

windows - How do I add a "New" Python script option to the context menu?

问题描述:

I'm trying to add a context menu option for New -> Python Script on Windows 7. However, everything I've tried has failed.

The way that I thought it should work is below:

Add the following registry key:

[HKEY_CLASSES_ROOT\.py\ShellNew]

"FileName"="Template.py"

Null File version:

[HKEY_CLASSES_ROOT\.py\ShellNew]

"NullFile"=""

Optional registry key

[HKEY_CLASSES_ROOT\.py]

"PerceivedType"="text/plain"

@="Python Script"

Add the file to the Windows, ShellNew folder...

This does nothing, although I've done this before, and it worked with other file types. I'm unable to find anything for this anywhere, because they do everything I try for other file types.

What am I doing wrong?

EDIT: Python 2.7.8 or later has this option added during setup/installation.

Reference: MSDN Extending Shortcut Menus

网友答案:
HKEY_CLASSES_ROOT\.py\PerceivedType="text" 

together with

HKEY_CLASSES_ROOT\.py\ShellNew\NullFile=""

works for me on Windows 7.

I have also set HKEY_CLASSES_ROOT\Python default value to "Python Script"


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.py]
@="Python"
"Content Type"="text/x-python"
"Python"="Python"
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.py\ShellNew]
"NullFile"=""

[HKEY_CLASSES_ROOT\Python]
@="Python Script"
网友答案:

Use open++. It's easy to configure, and maybe it can do what you want.

分享给朋友:
您可能感兴趣的文章:
随机阅读: