saleguas/context_menu

Support for passing filename to command

thescribe11 opened this issue · 5 comments

So, I absolutely love this project, but I have one problem: While I can pass the filename[s] to a Python function, I can't pass them to the command option. For normal Python code this isn't a big problem; however, compiling code with PyInstaller makes the python option unusable.

With that in mind, I would like it if you could add the ability to do something like this:

foo = menus.FastCommand('Foobar', type='FILES', command="foo ? ?", command_vars = ["FILENAME", "DIR"]

where command_vars is an iterable specifying the context menu-related variables (e.g. the filename or the current working directory) with which to replace the ?s in command.

Hm, I was curious how the python option would work with things such as pyinstaller. That's an extremely cool idea, and I never thought about it before. I'll try and implement this feature when I can and I'll close the issue then. Thanks for the feedback!

@saleguas You're welcome.

That's an extremely cool idea

I got it from Sqlite3's Python API.

i would propose a different style

foo = menus.FastCommand('Foobar', type='FILES', command=lambda file, dir: f"foo {file.name} {fir.name}", command_vars = ["FILENAME", "DIR"]

Where file and dir are pathlib.Path.

Implemented c2c4b02