2012-03-22 50 views
1

我已經在wxpython中使用wx.html創建了一個帶有幫助菜單項的菜單。我用的是如下代碼:wx.html中的超鏈接 - 如何在同一個html頁面內導航

class AboutDlg(wx.Frame): 


     def __init__(self, parent): 

      wx.Frame.__init__(self, parent, wx.ID_ANY, title="About", size=(400,400)) 

      html = wxHTML(self) 

      html.SetPage(
      '' 

      "<h2>About the About Tutorial</h2>" 

      "<p>This about box is for demo purposes only. It was created in June 2006" 

      "by Mike Driscoll.</p>" 

      "<p><b>Software used in making this demo:</h3></p>" 

      '<p><b><a href="http://www.python.org">Python 2.4</a></b></p>' 

      '<p><b><a href="http://www.wxpython.org">wxPython 2.8</a></b></p>' 
         ) 

    class wxHTML(wx.html.HtmlWindow): 
     def OnLinkClicked(self, link): 
      webbrowser.open(link.GetHref()) 

我發現代碼here

我想,當我在這些超鏈接之一點擊進入到其他HTML類我已創建。

示例:單擊在Python 2.4鏈接到HTML類名蟒蛇

我希望有人明白我想create..Thanks

+0

轉到[這裏](http://www.davesite.com/webstation/html/chap09.shtml)這個我想做的。 – TLSK 2012-03-22 21:54:21

回答

1

那麼,在OnLinkClicked方法,擺脫了網頁瀏覽器的東西,並把你的自定義代碼。我想你會想創建一些另外的HTML字符串,然後再次調用SetPage或者沿着這些行調用SetPage。或者你可以看看wxPython 2.9中的WebView的東西,它支持比HtmlWindow更多的LOT。