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",
)
Metadata
Release files for shellextools 0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shellextools-0.15.tar.gz | 19.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shellextools-0.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.2 kB
Release files / shellextools-0.15.tar.gz
| Download URL | shellextools-0.15.tar.gz |
|---|---|
| Size | 19.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d07bb93e2ede31bd9bb51b52ba653bd48a3eb90c48476cdc5c7e68406e54f482
|
|
BLAKE2b-256 checksum How to use checksums |
218dffce1dbd1ee779fca4990edf954f4882ec6da8bf34cc4ff0b3893a99d513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / shellextools-0.15-py3-none-any.whl
| Download URL | shellextools-0.15-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49bc6091779774d994bbadb0dbe046b5e5807f9436e2c7c1ce9bd56765c19788
|
|
BLAKE2b-256 checksum How to use checksums |
05fa53d8ccbd3c4851e0a85072ea91e237612b7e208ef3de3b70e4746fd56f33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|