greedist Posted January 7, 2023 Share Posted January 7, 2023 (edited) Currently, the results are supposed to be printed by pressing the space bar, but I want the results to be printed right away without pressing the space bar.  How do I modify it?  Thank you in advance đ Workflow Download  import sys sys.path.append("lib") import re from workflow import Workflow3 from hanspell_break import check def get_spell_check_data(sent): result = check(sent) r = result.as_dict() return r def main(wf): args = wf.args[0] # def wrapper(): # return get_spell_check_data(args) # res_json = wf.cached_data(args, wrapper, max_age=600) end_mark = re.search('\s+$', args) if end_mark: res_json = get_spell_check_data(args) out = f"{res_json['checked']}".rstrip() wf.add_item( title=out, subtitle="Press Enter to paste the results", arg=out, autocomplete=out, valid=True) wf.add_item(title=args, subtitle="Copy original text", autocomplete=args, arg=args, valid=True) wf.send_feedback() else: wf.logger.debug("args: %s" % args) wf.add_item(title=u'Press the spacebar to print the result', valid=False) wf.send_feedback() if __name__ == '__main__': wf = Workflow3() sys.exit(wf.run(main))  Edited January 7, 2023 by greedist Link to comment
vitor Posted January 7, 2023 Share Posted January 7, 2023 When asking for help with a workflow, please share the workflow itself. It doesnât seem like the problem is the code but that you have âArgument Requiredâ instead of âArgument Optionalâ in the object itself. Link to comment
greedist Posted January 7, 2023 Author Share Posted January 7, 2023 10 minutes ago, vitor said: When asking for help with a workflow, please share the workflow itself. It doesnât seem like the problem is the code but that you have âArgument Requiredâ instead of âArgument Optionalâ in the object itself. Â Thank you for your help đ I have corrected the text Link to comment
vitor Posted January 8, 2023 Share Posted January 8, 2023 Do the change mentioned above:  23 hours ago, vitor said: you have âArgument Requiredâ instead of âArgument Optionalâ in the object itself.   Two more tips, from a glance:Always prefer with input as argv instead of with input as {query}. There is a reason thatâs the default, it doesnât require custom escaping. In the Script box you use "${1}" instead of "{query}".The python3 ⌠|| /usr/bin/python3 ⌠complicates the code but doesnât offer any benefit. The second part (/usr/bin/python3) will never trigger because /usr/bin/python3 is already matched with python3. Link to comment
greedist Posted January 8, 2023 Author Share Posted January 8, 2023 16 minutes ago, vitor said: Do the change mentioned above:    Two more tips, from a glance: Always prefer with input as argv instead of with input as {query}. There is a reason thatâs the default, it doesnât require custom escaping. In the Script box you use "${1}" instead of "{query}". The python3 ⌠|| /usr/bin/python3 ⌠complicates the code but doesnât offer any benefit. The second part (/usr/bin/python3) will never trigger because /usr/bin/python3 is already matched with python3.   Thank you for your nice advice đ 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