import wx.html2
import re
import os
import cx_Oracle
class Main(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, style=wx.DEFAULT_FRAME_STYLE)
self.MainHtml2WebView = wx.html2.WebView.New(self, size=(0, 0), backend=wx.html2.WebViewBackendIE)
self.MainFirstPage()
def MainFirstPage(self):
self.FirstPage = """
<!DOCTYPE html>
<html lang=ko>
<style text=text/css>
html, body{{height:100%;}}
div.up{{margin:50px auto;}}
.button{{
width:400px;
background-color:orange;
border:none;
color:#fff;
padding:100px;
text-align:center;
text-decoration:none;
font-weight:bold;
font-size:100px;
margin:300px auto;
cursor:pointer;
}}
</style>
<head>
<meta charset=UTF-8>
<title>TITLE</title>
</head>
<body scroll="no">
<div class=up>
<center><img src=9.png></center>
</div>
<div class=down>
<center><input type=button class=button value=clcik onclick="location.href='{nextpage}'"></input></center>
</div>
</body>
</html>
"""
self.Department()
self.MainHtml2WebView.SetPage(self.FirstPage.format(nextpage=re.sub(r'\s+', " ", self.DepartmentChoie)), "")
def Department(self):
self.DepartmentChoie = """
<!DOCTYPE html>
<html lang=ko>
<style text=text/css>
html, body{{height:100%;}}
.obgy{{
width:500px;
background-color:orange;
border:none;
color:white;
padding:100px;
text-align:center;
text-decoration:none;
font-weight:bold;
font-size:50px;
margin:50px auto;
cursor:pointer;
position:relative;
}}
.pd{{
width:500px;
background-color:pink;
border:none;
color:white;
padding:100px;
text-align:center;
text-decoration:none;
font-weight:bold;
font-size:50px;
margin:50px auto;
cursor:pointer;
position:relative;
}}
.fm{{
width:500px;
background-color:blue;
border:none;
color:white;
padding:100px;
text-align:center;
text-decoration:none;
font-weight:bold;
font-size:50px;
margin:50px auto;
cursor:pointer;
position:relative;
}}
</style>
<head>
<meta charset=UTF-8 />
<title>TITLE2</title>
</head>
<body scroll=no>
<div>
<center>
<input type=button class=obgy value=TEST1 onclick="location.href='{obgypage}'">
<input type=button class=pd value=TEST2>
<input type=button class=fm value=TEST3>
</center>
</div>
</body>
</html>
"""
self.obgy()
self.MainHtml2WebView.SetPage(self.DepartmentChoie.format(obgypage=re.sub(r'\s+', " ", self.obgychoice)), "")
def obgy(self):
self.obgychoice = """
<!DOCTYPE html>
<html lang=ko>
<style text=text/css>
html, body{{height:100%;}}
.ob{{
width:500px;
background-color:orange;
border:none;
color:white;
padding:100px;
text-align:center;
text-decoration:none;
font-weight:bold;
font-size:50px;
margin:50px auto;
cursor:pointer;
position:relative;
}}
.gy{{
width:500px;
background-color:pink;
border:none;
color:white;
padding:100px;
text-align:center;
text-decoration:none;
font-weight:bold;
font-size:50px;
margin:50px auto;
cursor:pointer;
position:relative;
}}
</style>
<head>
<meta charset=UTF-8 />
<title>TITLE2</title>
</head>
<body scroll=no>
<div>
<center>
<input type=button class=ob value=TEST1></input>
<input type=button class=gy value=TEST2></input>
</center>
</div>
</body>
</html>
"""
if __name__ == '__main__':
app = wx.App()
fream = Main()
fream.Show(True)
app.MainLoop()
我的代码是使用wx.html2
的简单html。我使用input button tag
打开下一页。
严重吗?我发现了一些奇怪的东西。
第一个是当你加载页面时,如果在所有html中使用逗号,则无法加载页面;第二个是你必须使用正则表达式将所有html代码放在一行中。
我不知道为什么允许使用逗号,但这只能使用onclick = "location.href = ''"
函数。
第一页可以使用self.DepartmentChoie html
onclick = "location.href = '{nextpage}'"
无法调用第二页onclick = "location.href = '{obgypage}'"
。这是因为onclick = "location.href = ''"
函数有一个comma
。没有任何消息。
我尝试了无数种方式,但我只能使用onclick = "location.href = ''"
功能加载第一页。另一种我想知道如何使用按钮加载self.FirstPage -> self.DepartmentChoie -> self.obgychoice
页面的方法。其他模块也不错。其他方式也很好。我真的需要帮助