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