I’m new to working with the Anki codebase and developing add-ons. My aim with this post is to receive feedback / guidance from more experienced developers. The post will describe my goal, what I’ve done so far, the approach I’m pursuing as of right now and lastly a list of questions I’d like to have answered.
I’m trying to create an add-on that allows me to cut down on the time required to create new cards. I’m learning Russian. I’ve attached a picture of a card for a noun below and added some additional information. My process is as follows:
- Get lemmatized version of the word
- Look the word up on Wiktionary
- Copy accent
- Choose definition(s) and / or translation(s) and copy / create them myself
- Go to the russian Wiktionary page and retrieve declension table to paste in
- Go to Yandex and copy a suitable image
- Copy the example sentence from my ebook-reader
- Use forvo-dl to automatically retrieve audio file and paste it into the field
This process is also done for verbs and adjectives, although there are some differences. In general however, many of these steps can be automated. I have found a suitable data-source (openrussian database) that has most of the information I require.
The idea is that I get the lemmatized word, paste it into the first field, then hit a shortcut and the add-on will automatically paste in the accented version of the word, the declension table (or inflection for verbs).
As extensions going forward, I’d like to be able to automatically change the card type depending on the type of word (verb, noun adjective etc.).
What I’ve done so far:
I have familiarized myself with PyQt and Python.
So far I’ve added a new button to the editor view, registered a new short-cut to call my method, added some menu items, read values from Editor view fields and displayed some information. Just been trying some stuff.
I have downloaded add-ons and used them as references to see how other add-ons do these things. While looking through the add-ons I have often found myself digging into the Anki source-code to understand what’s going on (and still struggling). Doing even simple things seem to be needlessly cumbersome (although this might just be because I don’t know what I’m doing).
My proposed approach going forward
So far my approach would be to focus mainly on the Editor view. I’d read the value from the first input field, then have my add-on retrieve all of the required information and paste it in the other fields based on some configuration. Then save from the Editor view.
My questions are:
- Is my approach to read and write information to the Editor view (GUI) sensible?
- Is it easier (or possible) to create Cards differently and save directly to the deck (or to the database)?
- How does the split between Python / JS work in the Editor view?
- Are there any good resources I can read into to get a better overall understanding of how to interface with Anki?
- Are there any best practices for add-on development?
- Are there any well written add-ons that I can use to learn and to reference?