py文件
import os
import wx
import wx.html2
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, title="启动啦", size=(1000, 700))
# 创建一个Web视图组件
self.browser = wx.html2.WebView.New(self)
# 加载本地HTML文件
# self.browser.LoadURL('file:///D:\python\\flask\page.html')
# 获得当前路径
current_directory = os.path.dirname(os.path.abspath(__file__))
# print(current_directory)
self.browser.LoadURL('file:///'+current_directory+'\page.html')
# self.browser.LoadURL('http://127.0.0.1:5000')
# 显示主窗口
self.Show()
app = wx.App()
frame = MyFrame(None)
app.MainLoop()
html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>恭喜,站点创建成功!</title>
<style>
.container {
width: 60%;
margin: 10% auto 0;
background-color: #f0f0f0;
padding: 2% 5%;
border-radius: 10px
}
ul {
padding-left: 20px;
}
ul li {
line-height: 2.3
}
a {
color: #20a53a
}
</style>
</head>
<body>
<script>
function changetext(id)
{
id.innerHTML="点击啦222!";
}
</script>
<div class="container">
<h1 onclick="changetext(this)">点击文本!</h1>
</div>
</body>
</html>