When I tried the code below in FC 0.18【python version 3.6.6】, the html page would display successfully.
But in FC 0.19 and FC 0.20【both in python version 3.8.10】 it failed with an unhandled exception dialog showing. Also the report view said " Illegal storage access..."
Is it something wrong with the HTML file or the WebGui???
Code: Select all
import WebGui
import os
from mod.file_tools import get_path
browser = WebGui.openBrowserWindow('start')
html_path = os.path.join(get_path(), "welcome_page.html")
with open(html_path, "r", encoding="utf8") as file:
html_str = file.read()
html_str = html_str.replace("GIFPATH", "file:///" + os.path.join(get_path(), "images\welcome.gif"))
browser.setHtml(html_str)
Code: Select all
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Welcome</title>
<style>
.gif{width: 100%;height:100%;}
</style>
</head>
<body>
<div>
<img src="GIFPATH" class="gif">
</div>
</body>
</html>
After replacing the GIFPATH , html_str would be
'<!doctype html>\n<html>\n<head>\n <meta charset="UTF-8" />\n <title>Welcome</title>\n <style>\n .gif{width: 100%;height:100%;}\n </style>\n\n</head>\n<body>\n <div>\n <img src="file:///F:\\FreeCad 0.20\\Mod\\Design\\mod/../images\\welcome.gif" class="gif">\n </div>\n</body>\n</html>'