kanji-colorize
kanji-colorize copied to clipboard
Request: Bulk-add only to selected cards from browser or manually colorize from card editor (not on tab)
TL;DR: Is there a way to manually trigger the addon only when I need it / on a specific set of cards?
I love this addon but recently I had to change the output sizes and it's often been causing Anki to hang forever (requiring a force quit) when I tab out from the Expression field.
So I figured maybe a solution would be to comment out the "onFocusLost" bit of the code. But sadly that left me without the option of manually triggering it on a card-by-card basis (my deck is big, so regenerating all from the Menu eventually leads to a crash)
I figured having a way to bulk-add only to selected cards from the Browser menu (like the example below) would be a little more manageable and a way to invoke addon only when I need it.
Less ideally something on the right-click menu when editing a card (such as the example below) could also be an option if it's easier to code
I'm not familiar with coding, so the furthest I managed was creating the menu items by frankensteining other addons (as seen on the screenshots), but couldn't figure out how to get them to actually invoke the addKanji thingy,
If it's any help, this was my very shameful attempt for getting the right click menu to work (I have no experience coding, so be gentle on my ignorance)
def generate_from_card(flag, note, currentFieldIndex):
""" Basically I dumbly copied stuff from the onFocusLost part here """
return addKanji(note, flag, currentFieldIndex)
# Add right-click menu on card editor
def colContextMenuEvent(self, menu):
global editorWindow
editorWindow = self
do_generate_from_card = menu.addAction(_("Run Kanji Colorizer"))
do_generate_from_card.triggered.connect(generate_from_card)
#hook
addHook('EditorWebView.contextMenuEvent', colContextMenuEvent)
I tried to reference from the "onFocusLost" thing but clearly it wasn't as simple as copy pasting the
return addKanji(note, flag, currentFieldIndex)
under a new def for the menu to connect to.
Since it causes this error when trying to use it:
TypeError: generate_from_card() missing 2 required positional arguments: 'note' and 'currentFieldIndex'
Any tips on how to achieve the proper functionality would be greatly appreciated.