Skip to content

result

Attributes

Classes

Glyph

Bases: TypedDict

Flow Launcher Glyph

Source code in pyflowlauncher/result.py
25
26
27
28
class Glyph(TypedDict):
    """Flow Launcher Glyph"""
    Glyph: str
    FontFamily: str

Attributes

FontFamily instance-attribute
FontFamily: str
Glyph instance-attribute
Glyph: str

JsonRPCAction

Bases: TypedDict

Flow Launcher JsonRPCAction

Source code in pyflowlauncher/result.py
18
19
20
21
22
class JsonRPCAction(TypedDict):
    """Flow Launcher JsonRPCAction"""
    method: str
    parameters: Iterable
    dontHideAfterAction: NotRequired[bool]

Attributes

dontHideAfterAction instance-attribute
dontHideAfterAction: NotRequired[bool]
method instance-attribute
method: str
parameters instance-attribute
parameters: Iterable

PreviewInfo

Bases: TypedDict

Flow Launcher Preview section

Source code in pyflowlauncher/result.py
31
32
33
34
35
36
class PreviewInfo(TypedDict):
    """Flow Launcher Preview section"""
    PreviewImagePath: Optional[str]
    Description: Optional[str]
    IsMedia: bool
    PreviewDeligate: Optional[str]

Attributes

Description instance-attribute
Description: Optional[str]
IsMedia instance-attribute
IsMedia: bool
PreviewDeligate instance-attribute
PreviewDeligate: Optional[str]
PreviewImagePath instance-attribute
PreviewImagePath: Optional[str]

Result dataclass

Source code in pyflowlauncher/result.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@dataclass
class Result:
    Title: str
    SubTitle: Optional[str] = None
    IcoPath: Optional[Union[str, Path]] = None
    Score: int = 0
    JsonRPCAction: Optional[JsonRPCAction] = None
    ContextData: Optional[Iterable] = None
    Glyph: Optional[Glyph] = None
    CopyText: Optional[str] = None
    AutoCompleteText: Optional[str] = None
    RoundedIcon: bool = False
    Preview: Optional[PreviewInfo] = None

    def as_dict(self) -> Dict[str, Any]:
        return self.__dict__

    def add_action(self, method: Method,
                   parameters: Optional[Iterable[Any]] = None,
                   *,
                   dont_hide_after_action: bool = False) -> None:
        self.JsonRPCAction = {
            "method": method.__name__,
            "parameters": parameters or [],
            "dontHideAfterAction": dont_hide_after_action
        }

Attributes

AutoCompleteText class-attribute instance-attribute
AutoCompleteText: Optional[str] = None
ContextData class-attribute instance-attribute
ContextData: Optional[Iterable] = None
CopyText class-attribute instance-attribute
CopyText: Optional[str] = None
Glyph class-attribute instance-attribute
Glyph: Optional[Glyph] = None
IcoPath class-attribute instance-attribute
IcoPath: Optional[Union[str, Path]] = None
JsonRPCAction class-attribute instance-attribute
JsonRPCAction: Optional[JsonRPCAction] = None
Preview class-attribute instance-attribute
Preview: Optional[PreviewInfo] = None
RoundedIcon class-attribute instance-attribute
RoundedIcon: bool = False
Score class-attribute instance-attribute
Score: int = 0
SubTitle class-attribute instance-attribute
SubTitle: Optional[str] = None
Title instance-attribute
Title: str

Functions

add_action
add_action(method: Method, parameters: Optional[Iterable[Any]] = None, *, dont_hide_after_action: bool = False) -> None
Source code in pyflowlauncher/result.py
56
57
58
59
60
61
62
63
64
def add_action(self, method: Method,
               parameters: Optional[Iterable[Any]] = None,
               *,
               dont_hide_after_action: bool = False) -> None:
    self.JsonRPCAction = {
        "method": method.__name__,
        "parameters": parameters or [],
        "dontHideAfterAction": dont_hide_after_action
    }
as_dict
as_dict() -> Dict[str, Any]
Source code in pyflowlauncher/result.py
53
54
def as_dict(self) -> Dict[str, Any]:
    return self.__dict__

ResultResponse

Bases: TypedDict

Source code in pyflowlauncher/result.py
67
68
69
class ResultResponse(TypedDict):
    result: List[Dict[str, Any]]
    SettingsChange: NotRequired[Optional[Dict[str, Any]]]

Attributes

SettingsChange instance-attribute
SettingsChange: NotRequired[Optional[Dict[str, Any]]]
result instance-attribute
result: List[Dict[str, Any]]

Functions

send_results

send_results(results: Iterable[Result], settings: Optional[Dict[str, Any]] = None) -> ResultResponse

Formats and returns results as a JsonRPCResponse

Source code in pyflowlauncher/result.py
72
73
74
def send_results(results: Iterable[Result], settings: Optional[Dict[str, Any]] = None) -> ResultResponse:
    """Formats and returns results as a JsonRPCResponse"""
    return {'result': [result.as_dict() for result in results], 'SettingsChange': settings}