forked from HelenFoster/JSentenceHighlighter
/
JSentenceHighlighter.py
35 lines (27 loc) · 1.15 KB
/
JSentenceHighlighter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
# Copyright (C) 2017 Helen Foster
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# JSentenceHighlighter is an Anki addon for a Japanese vocab+sentence deck.
# It searches and marks the vocab word in the sentence.
# This file belongs with the "jsentencehighlighter" folder:
# the README might be inside depending on how you received this!
from aqt import mw
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QAction
from anki.hooks import addHook
def highlightSentences(nids = None):
import jsentencehighlighter.run as run
reload (run)
run.highlightSentences(nids)
action = QAction("Highlight sentences", mw)
mw.connect(action, SIGNAL("triggered()"), highlightSentences)
mw.form.menuTools.addAction(action)
def setupMenu(browser):
buttonText = "Highlight Japanese Sentences"
a = QAction(buttonText, browser)
browser.connect(a, SIGNAL("triggered()"), lambda e=browser: onRegenerate(e))
browser.form.menuEdit.addSeparator()
browser.form.menuEdit.addAction(a)
def onRegenerate(browser):
highlightSentences(browser.selectedNotes())
addHook("browser.setupMenus", setupMenu)