abunav Posted October 3, 2020 Share Posted October 3, 2020 (edited) Basically the title. I am using a python script which will return a list in one of its functions. How can I display the elements of that list as options in Alfred? Example: def func(): #some code here return a # a = ["A", "B", "C", "D"] for example How do I get "A", "B", "C", "D" to be the 4 options in an Alfred drop down like below: Edited October 3, 2020 by abunav Link to comment
vitor Posted October 3, 2020 Share Posted October 3, 2020 You’ll have to return JSON on a Script Filter. Link to comment
abunav Posted October 4, 2020 Author Share Posted October 4, 2020 (edited) Not quite sure how I can tie in the Python script here. What I want is that the python script be executed upon a keyword trigger, and the JSON object thus generated in the script be used as list items in Alfred. Edited October 4, 2020 by abunav Link to comment
vitor Posted October 4, 2020 Share Posted October 4, 2020 10 hours ago, abunav said: Not quite sure how I can tie in the Python script here. Do you know how to generate JSON from Python? That’s all you need to do (send it to the standard output) in the specified format. For your example, it would be something like {"items": [ { "title": "A", "arg": "something to do with A" }, { "title": "B", "arg": "something to do with B" }, { "title": "C", "arg": "something to do with C" }, ]} 10 hours ago, abunav said: What I want is that the python script be executed upon a keyword trigger, and the JSON object thus generated in the script be used as list items in Alfred. What you want is a Script Filter; that’s exactly what they’re for. Any other method will be a longer workaround. abunav 1 Link to comment
abunav Posted October 5, 2020 Author Share Posted October 5, 2020 Thanks a lot, I've got it working! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now