I am using Anki flash card program which is written in Python. I want to write my first addition. I am new to Python. I am not a technical expert, but I have several years of experience jumping inside other people's code in Java, C ++, C #, etc.
A flash card shows a question, for example, "Capital of France?". When the "Show Answer" button is clicked, Anki displays the answer "Paris".
I want to take this text “Paris” before it appears.
I came to this point in Anki code. At this point, the map displays "Capital of France?". The answer is still empty. I think I want to be able to capture "val" (which, I think, "Paris") and use it in my expansion.
def _getTypedAnswer(self):
self.web.evalWithCallback("typeans ? typeans.value : null", self._onTypedAnswer)
def _onTypedAnswer(self, val):
self.typedAnswer = val
self._showAnswer()
I searched the search terms to find the meaning of this:
("typeans ? typeans.value : null", self._onTypedAnswer)
, , .
.
: .
Anki . , .
"webview":
def evalWithCallback(self, js, cb):
self.page().runJavaScript(js, cb)
"" . "mw" ( " " )
init ""
def __init__(self, mw):
self.mw = mw
self.web = mw.web