From 6816163c08db56bdf807499e5d31ded3f693b5d8 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 10 Apr 2011 16:49:21 +0900 Subject: [PATCH] add the bridge after the page has loaded --- aqt/editor.py | 3 +-- aqt/webview.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index 32ab1c938..37bf00c7e 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -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 diff --git a/aqt/webview.py b/aqt/webview.py index f7727a56b..af16df1b0 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -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(""" @@ -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