mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
scroll to answer
This commit is contained in:
parent
4aa958a40f
commit
ae776365b1
1 changed files with 9 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
|
from PyQt4.QtWebKit import QWebPage
|
||||||
import anki, anki.utils
|
import anki, anki.utils
|
||||||
from anki.sound import playFromText, stripSounds
|
from anki.sound import playFromText, stripSounds
|
||||||
from anki.latex import renderLatex, stripLatex
|
from anki.latex import renderLatex, stripLatex
|
||||||
|
@ -21,6 +22,8 @@ class View(object):
|
||||||
self.main = parent
|
self.main = parent
|
||||||
self.body = body
|
self.body = body
|
||||||
self.frame = frame
|
self.frame = frame
|
||||||
|
self.main.connect(self.body, SIGNAL("loadFinished(bool)"),
|
||||||
|
self.onLoadFinished)
|
||||||
|
|
||||||
# State control
|
# State control
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -119,10 +122,15 @@ class View(object):
|
||||||
"Show the answer."
|
"Show the answer."
|
||||||
a = self.main.currentCard.htmlAnswer()
|
a = self.main.currentCard.htmlAnswer()
|
||||||
a = renderLatex(self.main.deck, a)
|
a = renderLatex(self.main.deck, a)
|
||||||
self.write(stripSounds(a))
|
self.write('<span id=answer />' + stripSounds(a))
|
||||||
if self.state != self.oldState:
|
if self.state != self.oldState:
|
||||||
playFromText(a)
|
playFromText(a)
|
||||||
|
|
||||||
|
def onLoadFinished(self):
|
||||||
|
if self.state == "showAnswer":
|
||||||
|
mf = self.body.page().mainFrame()
|
||||||
|
mf.evaluateJavaScript("location.hash = 'answer'")
|
||||||
|
|
||||||
# Top section
|
# Top section
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue