27 import wx |
27 import wx |
28 import wx.html |
28 import wx.html |
29 |
29 |
30 HtmlFrameOpened = [] |
30 HtmlFrameOpened = [] |
31 |
31 |
|
32 |
32 def OpenHtmlFrame(self, title, file, size): |
33 def OpenHtmlFrame(self, title, file, size): |
33 if title not in HtmlFrameOpened: |
34 if title not in HtmlFrameOpened: |
34 HtmlFrameOpened.append(title) |
35 HtmlFrameOpened.append(title) |
35 window = HtmlFrame(self, HtmlFrameOpened) |
36 window = HtmlFrame(self, HtmlFrameOpened) |
36 window.SetTitle(title) |
37 window.SetTitle(title) |
39 window.Show() |
40 window.Show() |
40 |
41 |
41 [ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)] |
42 [ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)] |
42 EVT_HTML_URL_CLICK = wx.NewId() |
43 EVT_HTML_URL_CLICK = wx.NewId() |
43 |
44 |
|
45 |
44 class HtmlWindowUrlClick(wx.PyEvent): |
46 class HtmlWindowUrlClick(wx.PyEvent): |
45 def __init__(self, linkinfo): |
47 def __init__(self, linkinfo): |
46 wx.PyEvent.__init__(self) |
48 wx.PyEvent.__init__(self) |
47 self.SetEventType(EVT_HTML_URL_CLICK) |
49 self.SetEventType(EVT_HTML_URL_CLICK) |
48 self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget()) |
50 self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget()) |
|
51 |
49 |
52 |
50 class UrlClickHtmlWindow(wx.html.HtmlWindow): |
53 class UrlClickHtmlWindow(wx.html.HtmlWindow): |
51 """ HTML window that generates and OnLinkClicked event. |
54 """ HTML window that generates and OnLinkClicked event. |
52 |
55 |
53 Use this to avoid having to override HTMLWindow |
56 Use this to avoid having to override HTMLWindow |
58 def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY): |
61 def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY): |
59 if event == HtmlWindowUrlClick: |
62 if event == HtmlWindowUrlClick: |
60 self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler) |
63 self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler) |
61 else: |
64 else: |
62 wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2) |
65 wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2) |
|
66 |
63 |
67 |
64 class HtmlFrame(wx.Frame): |
68 class HtmlFrame(wx.Frame): |
65 def _init_ctrls(self, prnt): |
69 def _init_ctrls(self, prnt): |
66 wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame', |
70 wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame', |
67 parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616), |
71 parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616), |