我正在使用wxPython(wxAUI)編寫一個小型報表應用程序。我想將我的數據呈現爲HTML,以顯示在WebView的「小部件」中。我正在尋找一個示例「hello world」片段,它將顯示如何在WebView小部件中顯示/呈現HTML字符串 - 但一直未能找到一個示例 - 並且WebView小部件似乎沒有很好的文檔記錄。wxPython WebView示例
是否有人可以提供一個鏈接到這樣的例子或(更好的是),在這裏發佈一個簡短的片段,展示如何使用WebView小部件來呈現HTML字符串?
# sample html string to display in WebView widget
html_string = """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Hello World!</title>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css" src="main.css"></style>
</head>
<body>
<span id="foo">The quick brown fox jumped over the lazy dog</span>
<script type="text/javascript">
$(document.ready(function(){
$("span#foo").click(function(){ alert('I was clicked!'); });
});
</script>
</body>
</html>
"""
這是一個古老的問題,但如果我的答案被標記爲答案將會很好。 – RufusVS 2018-02-06 23:36:32