Jump to content

[SOLVED] How can I list out options using an output from a Python script?


Recommended Posts

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:

 

image.png.3c3732d9902b1bc718eb615fb20f9eb1.png

Edited by abunav
Link to post
Posted (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 by abunav
Link to post
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.

Link to post
  • vitor changed the title to [SOLVED] How can I list out options using an output from a Python script?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...