mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add the bridge after the page has loaded
This commit is contained in:
parent
b8f03c298b
commit
6816163c08
2 changed files with 2 additions and 3 deletions
|
@ -303,6 +303,7 @@ class Editor(object):
|
|||
######################################################################
|
||||
|
||||
def bridge(self, str):
|
||||
print "bridge", str
|
||||
if not self.fact or not runHook:
|
||||
# shutdown
|
||||
return
|
||||
|
@ -310,7 +311,6 @@ class Editor(object):
|
|||
if str.startswith("blur") or str.startswith("key"):
|
||||
(type, txt) = str.split(":", 1)
|
||||
self.fact._fields[self.currentField] = self.mungeHTML(txt)
|
||||
print "save fact", txt
|
||||
if type == "blur":
|
||||
if not self._keepButtons:
|
||||
self.disableButtons()
|
||||
|
@ -463,7 +463,6 @@ class Editor(object):
|
|||
def saveTagsAndGroup(self):
|
||||
self.fact.gid = self.mw.deck.groupId(unicode(self.group.text()))
|
||||
self.fact.tags = parseTags(unicode(self.tags.text()))
|
||||
print "update tags to ", self.fact.tags
|
||||
self.fact.flush()
|
||||
|
||||
# Format buttons
|
||||
|
|
|
@ -86,7 +86,6 @@ class AnkiWebView(QWebView):
|
|||
if loadCB:
|
||||
self._loadFinishedCB = loadCB
|
||||
QWebView.setHtml(self, html)
|
||||
self.page().mainFrame().addToJavaScriptWindowObject("py", self._bridge)
|
||||
def stdHtml(self, body, css="", bodyClass="", loadCB=None):
|
||||
self.setHtml("""
|
||||
<html><head><style>%s</style>
|
||||
|
@ -107,6 +106,7 @@ class AnkiWebView(QWebView):
|
|||
def _linkHandler(self, url):
|
||||
self.linkHandler(unicode(url.toString()))
|
||||
def _loadFinished(self):
|
||||
self.page().mainFrame().addToJavaScriptWindowObject("py", self._bridge)
|
||||
if self._loadFinishedCB:
|
||||
self._loadFinishedCB(self)
|
||||
self._loadFinishedCB = None
|
||||
|
|
Loading…
Reference in a new issue