(Parent, id, pos, size, style)
| S.N. |
樣式和說明
|
|---|---|
| 1 |
wxHW_SCROLLBAR_NEVER
永遠不顯示滾動條,即使是頁面比窗口大
|
| 2 |
wxHW_SCROLLBAR_AUTO
只有在頁面大小超過窗口大小顯示滾動條
|
| 3 |
wxHW_NO_SELECTION
不要讓用戶選擇文本
|
| S.N. |
事件和說明
|
|---|---|
| 1 |
EVT_HTML_CELL_CLICKED
一個wxHtmlCell被點擊
|
| 2 |
EVT_HTML_CELL_HOVER
鼠標經(jīng)過wxHtmlCell
|
| 3 |
EVT_HTML_LINK_CLICKED
wxHtmlCell其中包含一個超鏈接被點擊
|
| S.N. |
函數(shù)與說明
|
|---|---|
| 1 |
AppendToPage()
HTML追加到當前顯示的文字片段,并刷新窗口
|
| 2 |
HistoryBack()
又回到了以前訪問過的網(wǎng)頁
|
| 3 |
HistoryForward()
轉(zhuǎn)到歷史的下一頁
|
| 4 |
LoadPage()
加載一個HTML文件
|
| 5 |
OnLinkClicked()
超鏈接被點擊時調(diào)用
|
| 6 |
SetPage()
設(shè)置標記HTML的標簽,文字作為頁面內(nèi)容
|
下面的代碼顯示一個簡單的HTML瀏覽器。上運行的代碼,一個TextEntry對話框彈出要求輸入URL。wx.HtmlWindow類的LoadPage()方法顯示內(nèi)容在窗口中。
import wx
import wx.htmll
class MyHtmlFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title, size = (600,400))
html = wx.htmll.HtmlWindow(self)
if "gtk2" in wx.PlatformInfo:
html.SetStandardFonts()
dlg = wx.TextEntryDialog(self, 'Enter a URL', 'HTMLWindow')
if dlg.ShowModal() == wx.ID_OK:
html.LoadPage(dlg.GetValue())
app = wx.App()
frm = MyHtmlFrame(None, "Simple HTML Browser")
frm.Show()
app.MainLoop()
執(zhí)行上面的代碼,產(chǎn)生以下結(jié)果: