From 59efefc0188a19022b31b4668130a4fc7e1a7d26 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 28 Dec 2021 17:57:40 +1100 Subject: [PATCH] add context menu + methods --- main.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 4056853..bfb98c9 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ sys.path.append(os.path.join(parent_folder_path, 'plugin')) from flowlauncher import FlowLauncher +import webbrowser class HelloWorld(FlowLauncher): @@ -15,11 +16,11 @@ def query(self, query): return [ { "Title": "Hello World, this is where title goes. {}".format(('Your query is: ' + query , query)[query == '']), - "SubTitle": "This is where your subtitle goes", + "SubTitle": "This is where your subtitle goes, press enter to open Flow's url", "IcoPath": "Images/app.png", "JsonRPCAction": { - "method": "do_something_for_query", - "parameters": [param1, param2] + "method": "open_url", + "parameters": ["https://github.com/Flow-Launcher/Flow.Launcher"] } } ] @@ -27,14 +28,18 @@ def query(self, query): def context_menu(self, data): return [ { - "Title": "Context menu entry", - "SubTitle": "Data: {}".format(data), - "IcoPath": "Images/app.ico", + "Title": "Hello World Python's Context menu", + "SubTitle": "Press enter to open Flow the plugin's repo in GitHub", + "IcoPath": "Images/app.png", + "JsonRPCAction": { + "method": "open_url", + "parameters": ["https://github.com/Flow-Launcher/Flow.Launcher.Plugin.HelloWorldPython"] + } } ] - def do_something_for_query(self, param1, param2): - pass + def open_url(self, url): + webbrowser.open(url) if __name__ == "__main__": HelloWorld()