Convert renderer string to Template()

This commit is contained in:
Ken Roberts 2016-06-15 08:05:05 -07:00
parent a4483af5b4
commit b627736e5e
1 changed files with 11 additions and 10 deletions

View File

@ -22,6 +22,7 @@
import re
from string import Template
from PyQt5 import QtGui, QtCore, QtWebKitWidgets
from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, RegistryMixin, Settings
@ -371,22 +372,22 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties):
self.web_frame = self.web.page().mainFrame()
# Adjust width and height to account for shadow. outline done in css.
# TODO: Tested at home
html = """<!DOCTYPE html><html><head><script>
function show_text(newtext) {{
html = Template("""<!DOCTYPE html><html><head><script>
function show_text(newtext) {
var main = document.getElementById('main');
main.innerHTML = newtext;
// We need to be sure that the page is loaded, that is why we
// return the element's height (even though we do not use the
// returned value).
return main.offsetHeight;
}}
</script><style>*{{margin: 0; padding: 0; border: 0;}}
#main {{position: absolute; top: 0px; {format_css} {outline_css}}}</style></head><body>
<div id="main"></div></body></html>""".format(format_css=build_lyrics_format_css(theme_data,
self.page_width,
self.page_height),
outline_css=build_lyrics_outline_css(theme_data))
self.web.setHtml(html)
}
</script><style>*{margin: 0; padding: 0; border: 0;}
#main {position: absolute; top: 0px; ${format_css} ${outline_css}}</style></head><body>
<div id="main"></div></body></html>""")
self.web.setHtml(html.substitute(format_css=build_lyrics_format_css(theme_data,
self.page_width,
self.page_height),
outline_css=build_lyrics_outline_css(theme_data)))
self.empty_height = self.web_frame.contentsSize().height()
def _paginate_slide(self, lines, line_end):