Ankirspy

Samuel Lee's Avatar

Samuel Lee

15 Jan, 2020 05:36 AM

I cannot install the module ankirspy to get working on an addon that I would like

  1. Support Staff 1 Posted by Damien Elmes on 15 Jan, 2020 11:51 PM

    Damien Elmes's Avatar

    Hi Sam,

    That sounds like you're trying to run an add-on outside of Anki. That won't work - you need to copy/move it to the addons folder then start Anki.

  2. 2 Posted by Samuel Lee on 15 Jan, 2020 11:55 PM

    Samuel Lee's Avatar

    https://apps.ankiweb.net/docs/addons.html

    I'm following this link though and have been running this:

    It has led to the ankirspy module not found error.

    from aqt import gui_hooks

    def myfunc():
      print("myfunc")

    gui_hooks.reviewer_did_show_answer.append(myfunc)

  3. Support Staff 3 Posted by Damien Elmes on 16 Jan, 2020 12:18 AM

    Damien Elmes's Avatar

    You can not run the add-on outside of Anki. You need to copy it into your add-on folder, then start Anki to run it.

  4. 4 Posted by Samuel Lee on 16 Jan, 2020 02:22 AM

    Samuel Lee's Avatar

    Hi,

    I put it in Anki, but nothing happened. I tried the simple add on example
    and put it in Anki and saw no effect after restarting Anki. I think there
    is something wrong with getting the ankirspy package.

    Sam

  5. Support Staff 5 Posted by Damien Elmes on 16 Jan, 2020 02:38 AM

    Damien Elmes's Avatar

    That hook is coming in 2.1.20, which is not yet in beta testing. I added a note on the page about it, but you may have been looking at the page before the note was added, so I'm sorry if there was confusion. The examples on the rest of the page with the exception of the new hooks section should work however.

  6. 6 Posted by Samuel Lee on 16 Jan, 2020 10:32 PM

    Samuel Lee's Avatar

    Hi Damien,

    Thanks so much! I've got the test function to run now. I'm hoping to export
    note ids into a spreadsheet every time you hit synchronize or close. Where
    can I link my function to the synchronize action? I'm having trouble
    finding that on github. Any help would be appreciated. Anki is awesome!

    Samuel Lee

  7. Support Staff 7 Posted by Damien Elmes on 17 Jan, 2020 05:29 AM

    Damien Elmes's Avatar

    Hi Sam,

    Using the just-released 2.1.20beta1, you can see all the available hooks in hooks.py and gui_hooks.py. The collection unloading hook may be what you want. I'm afraid I can't offer support for add-on writing, but if you get stuck, the code of other add-ons can be a useful way to learn how things are done.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac