]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxHtmlWindow.py
07ec21a554bf6400e9924e29cee245f01d7f4c7a
[wxWidgets.git] / utils / wxPython / demo / wxHtmlWindow.py
1
2 from wxPython.wx import *
3 from wxPython.html import *
4 from wxPython.lib.sizers import *
5
6 #----------------------------------------------------------------------
7
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)
13 self.log = log
14
15 def OnLinkClicked(self, link):
16 self.log.WriteText('OnLinkClicked: %s\n' % link)
17
18 # Virtuals in the base class have been renamed with base_ on the font.
19 self.base_OnLinkClicked(link)
20
21
22
23 class TestHtmlPanel(wxPanel):
24 def __init__(self, parent, frame, log):
25 wxPanel.__init__(self, parent, -1)
26 self.log = log
27 self.frame = frame
28
29
30 self.html = MyHtmlWindow(self, -1, log)
31 self.html.SetRelatedFrame(frame, "wxPython: (A Demonstration) -- %s")
32 self.html.SetRelatedStatusBar(0)
33
34 self.box = box.wxBoxSizer(wxVERTICAL)
35 self.box.Add(self.html, 1)
36
37 subbox = wxBoxSizer(wxHORIZONTAL)
38 btn = wxButton(self, 1201, "Show Default")
39 EVT_BUTTON(self, 1201, self.OnShowDefault)
40 subbox.Add(btn, 1)
41
42 btn = wxButton(self, 1202, "Load File")
43 EVT_BUTTON(self, 1202, self.OnLoadFile)
44 subbox.Add(btn, 1)
45
46 btn = wxButton(self, 1203, "With Widgets")
47 EVT_BUTTON(self, 1203, self.OnWithWidgets)
48 subbox.Add(btn, 1)
49
50 btn = wxButton(self, 1204, "Back")
51 EVT_BUTTON(self, 1204, self.OnBack)
52 subbox.Add(btn, 1)
53
54 btn = wxButton(self, 1205, "Forward")
55 EVT_BUTTON(self, 1205, self.OnForward)
56 subbox.Add(btn, 1)
57
58 self.box.Add(subbox)
59 self.OnShowDefault(None)
60
61
62 def OnSize(self, event):
63 size = self.GetClientSize()
64 self.box.Layout(size)
65
66
67 def OnShowDefault(self, event):
68 self.html.LoadPage("data/test.htm")
69
70
71 def OnLoadFile(self, event):
72 pass
73
74
75 def OnWithWidgets(self, event):
76 pass
77
78 def OnBack(self, event):
79 if not self.html.HistoryBack():
80 wxMessageBox("No more items in history!")
81
82 def OnForward(self, event):
83 if not self.html.HistoryForward():
84 wxMessageBox("No more items in history!")
85
86
87 #----------------------------------------------------------------------
88
89 def runTest(frame, nb, log):
90 win = TestHtmlPanel(nb, frame, log)
91 return win
92
93
94 #----------------------------------------------------------------------
95
96
97
98
99
100 overview = """\
101 wxHtmlWindow is capable of parsing and rendering most simple HTML tags.
102
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...
104
105 """
106