]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxHtmlWindow.py
07ec21a554bf6400e9924e29cee245f01d7f4c7a
2 from wxPython
. wx
import *
3 from wxPython
. html
import *
4 from wxPython
. lib
. sizers
import *
6 #----------------------------------------------------------------------
8 # This shows how to catch the OnLinkClicked non-event. (It's a virtual
9 # method in the C++ code...)
10 class MyHtmlWindow ( wxHtmlWindow
):
11 def __init__ ( self
, parent
, id , log
):
12 wxHtmlWindow
.__ init
__ ( self
, parent
, id )
15 def OnLinkClicked ( self
, link
):
16 self
. log
. WriteText ( 'OnLinkClicked: %s \n ' % link
)
18 # Virtuals in the base class have been renamed with base_ on the font.
19 self
. base_OnLinkClicked ( link
)
23 class TestHtmlPanel ( wxPanel
):
24 def __init__ ( self
, parent
, frame
, log
):
25 wxPanel
.__ init
__ ( self
, parent
, - 1 )
30 self
. html
= MyHtmlWindow ( self
, - 1 , log
)
31 self
. html
. SetRelatedFrame ( frame
, "wxPython: (A Demonstration) -- %s " )
32 self
. html
. SetRelatedStatusBar ( 0 )
34 self
. box
= box
. wxBoxSizer ( wxVERTICAL
)
35 self
. box
. Add ( self
. html
, 1 )
37 subbox
= wxBoxSizer ( wxHORIZONTAL
)
38 btn
= wxButton ( self
, 1201 , "Show Default" )
39 EVT_BUTTON ( self
, 1201 , self
. OnShowDefault
)
42 btn
= wxButton ( self
, 1202 , "Load File" )
43 EVT_BUTTON ( self
, 1202 , self
. OnLoadFile
)
46 btn
= wxButton ( self
, 1203 , "With Widgets" )
47 EVT_BUTTON ( self
, 1203 , self
. OnWithWidgets
)
50 btn
= wxButton ( self
, 1204 , "Back" )
51 EVT_BUTTON ( self
, 1204 , self
. OnBack
)
54 btn
= wxButton ( self
, 1205 , "Forward" )
55 EVT_BUTTON ( self
, 1205 , self
. OnForward
)
59 self
. OnShowDefault ( None )
62 def OnSize ( self
, event
):
63 size
= self
. GetClientSize ()
67 def OnShowDefault ( self
, event
):
68 self
. html
. LoadPage ( "data/test.htm" )
71 def OnLoadFile ( self
, event
):
75 def OnWithWidgets ( self
, event
):
78 def OnBack ( self
, event
):
79 if not self
. html
. HistoryBack ():
80 wxMessageBox ( "No more items in history!" )
82 def OnForward ( self
, event
):
83 if not self
. html
. HistoryForward ():
84 wxMessageBox ( "No more items in history!" )
87 #----------------------------------------------------------------------
89 def runTest ( frame
, nb
, log
):
90 win
= TestHtmlPanel ( nb
, frame
, log
)
94 #----------------------------------------------------------------------
101 wxHtmlWindow is capable of parsing and rendering most simple HTML tags.
103 It is not intended to be a high-end HTML browser. If you're looking for something like that try http://www.mozilla.org - there's a chance you'll be able to make their widget wxWindows-compatible. I'm sure everyone will enjoy your work in that case...