For my add-on I need to “catch” the event of a new card being added and have it trigger a function. However the basic code below does not work. There are no errors, but my debug print statement does not appear in the console when I add a new card. What am I doing wrong here?
from aqt import mw
from aqt import gui_hooks
def print_debug(note) -> None:
print("New card added!")
gui_hooks.add_cards_did_add_note.append(print_debug)
Maybe AnkiConnect is editing the card data directly and adding new cards, Anki functions are not used so gui_hooks are not called. You may need to detect the add cards by AnkiConnect or Yomitan in some other way or fork AnkiConnect. (I don’t know exactly)