Skip to content
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

For Python plugins, what is the data argument passing in the 'context_menu' function? #49

Open
falldeaf opened this issue May 23, 2022 · 1 comment

Comments

@falldeaf
Copy link

falldeaf commented May 23, 2022

For some reason all of the plugin references (https://www.flowlauncher.com/docs/#/py-plugin-references) seem to implement a different API than the hello world plugin. It looks like because they're porting from Wox using the flox library, maybe?

So if I am opening a context menu, I need to pass through some kind of unique ID for whichever query result was selected. In the Steam plugin (https://github.com/Garulf/Steam-Search/blob/main/plugin/main.py) they're passing a 'context' variable through the 'add_item' method and getting that data in the data array, first index (data[0]).

In the Hello World example though, how can I get a UID for whichever query item was selected when entering the context menu?

@falldeaf falldeaf changed the title For Python plugins, what is the data argument passing? For Python plugins, what is the data argument passing in the 'context_menu' function? May 23, 2022
@Garulf
Copy link
Member

Garulf commented Jul 28, 2022

Sorry I some how missed this issue.

I think it's easiest to provide an example:

def query(self, query):
    results = []
    for i in range(10):
        results.append(
            {
                'Title': i,
                'SubTitle': 'Subtitle',
                'ContextData': ['context1', 'context2']
            }
        )
    print(json.dumps(results))

def context_menu(self, data):
    context1, context2 = data
    results = [
        {
            'Title': context1,
            'SubTitle': context2,
        }
    ]
    print(json.dumps(results))
    

When the context menu is invoked the ContextData field is passed to the context_menu method as a list.

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

No branches or pull requests

2 participants