Adds Python functions/methods to the Windows context menu
Project description
Adds Python functions/methods to the Windows context menu
pip install shellextools
Here are some examples:
https://github.com/hansalemaos/ripgrepgui
https://github.com/hansalemaos/rc_collage
https://github.com/hansalemaos/rc_pictools
https://github.com/githubrobbi/Ultra-Fast-File-Search
Create a pyw file
from PIL import Image
from hackyargparser import add_sysargv
from shellextools import (
format_folder_drive_path_backslash,
add_multicommands_files,
change_file_extension,
)
import sys
@add_sysargv
def main(path: str = "", action: str = ""):
path = format_folder_drive_path_backslash(path)
img = Image.open(path)
if action == "convert2ico":
iconfi = change_file_extension(path=path, extension="ico")
img.resize((512, 512)).save(iconfi)
if action == "convert2gray":
iconfi = change_file_extension(path=path, prefix="gray_", extension="png")
img.convert("L").save(iconfi)
if action == "convert2bw":
iconfi = change_file_extension(path=path, prefix="bw_", extension="png")
img.convert("1").save(iconfi)
return 0
if __name__ == "__main__":
if len(sys.argv) == 1:
futurnameofcompiledexe = "pictools.exe"
multicommands = [
{
"mainmenuitem": "PicTools",
"submenu": "Convert to .ico",
"folderinprogramdata": "RCTools",
"filetypes": ["bmp", "png", "jpg", "jpeg"],
"additional_arguments": "--action convert2ico",
},
{
"mainmenuitem": "PicTools",
"submenu": "Convert to grayscale",
"folderinprogramdata": "RCTools",
"filetypes": ["bmp", "png", "jpg", "jpeg"],
"additional_arguments": "--action convert2gray",
},
{
"mainmenuitem": "PicTools",
"submenu": "Convert to bw",
"folderinprogramdata": "RCTools",
"filetypes": ["bmp", "png", "jpg", "jpeg"],
"additional_arguments": "--action convert2bw",
},
]
add_multicommands_files(multicommands, futurnameofcompiledexe)
else:
main()
Compile it with nutika
from nutikacompile import compile_with_nuitka
wholecommand = compile_with_nuitka(
pyfile=r"C:\ProgramData\anaconda3\envs\nu\pictools.pyw",
icon=r"C:\Users\hansc\Downloads\cova.jpg",
disable_console=True,
file_version="1.0.0.0",
onefile=True,
outputdir="c:\\nuitkapictoicon",
addfiles=[
],
delete_onefile_temp=False, # creates a permanent cache folder
needs_admin=True,
arguments2add="--msvc=14.3 --noinclude-numba-mode=nofollow",
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shellextools-0.15.tar.gz
(19.2 kB
view details)
Built Distribution
File details
Details for the file shellextools-0.15.tar.gz
.
File metadata
- Download URL: shellextools-0.15.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d07bb93e2ede31bd9bb51b52ba653bd48a3eb90c48476cdc5c7e68406e54f482 |
|
MD5 | 20e8cf8ca0c4cfb0e951a1ae514f53c6 |
|
BLAKE2b-256 | 218dffce1dbd1ee779fca4990edf954f4882ec6da8bf34cc4ff0b3893a99d513 |
File details
Details for the file shellextools-0.15-py3-none-any.whl
.
File metadata
- Download URL: shellextools-0.15-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49bc6091779774d994bbadb0dbe046b5e5807f9436e2c7c1ce9bd56765c19788 |
|
MD5 | c22b0798c7bd5c0de14801a6be456b0e |
|
BLAKE2b-256 | 05fa53d8ccbd3c4851e0a85072ea91e237612b7e208ef3de3b70e4746fd56f33 |