pyFlowLauncher is an API that allows you to quickly create plugins for Flow Launcher!
Install via pip:
python -m pip install pyflowlauncher[all]Important
Please use the [all] flag in order to support Python versions older then 3.11.
A basic plugin using a function as the query method.
from pyflowlauncher import Plugin, Result
plugin = Plugin()
@plugin.on_method
def query(query: str):
yield Result(
title="This is a title!",
subtitle="This is the subtitle!",
icon="icon.png"
)
plugin.run()Methods decorated with @plugin.on_method can yield one or more Result objects, return a list of Result objects, or return a single Result — the framework normalizes all forms into the correct response automatically.
A more advanced usage using a Method class as the query method.
from pyflowlauncher import Plugin, Result, Method
from .models.json_rpc import JsonRPCResponse
plugin = Plugin()
class Query(Method):
def __call__(self, query: str) -> JsonRPCResponse:
r = Result(
title="This is a title!",
subtitle="This is the subtitle!"
)
self.add_result(r)
return self.return_results()
plugin.add_method(Query())
plugin.run()Plugin ships with a built-in context_menu method: put Result objects in a
result's context_data and they become that result's context menu — no handler
code required.
from pyflowlauncher import Plugin, Result
plugin = Plugin()
@plugin.on_method
def query(query: str):
yield Result(
title="This is a title!",
subtitle="Right-click me for a context menu.",
context_data=[
Result(title="This is a context menu item!"),
Result(title="So is this!"),
],
)
plugin.run()Menu items are full Result objects, so they can carry actions via
add_action() just like query results.
If you need more control (for example, building the menu lazily when it is
opened), register your own context_menu — it replaces the built-in one:
@plugin.on_method
def context_menu(context_data):
yield Result(title=f"Menu for {context_data[0]}")