1 | #!/usr/bin/python |
---|
2 | """ |
---|
3 | Help panel for data_loader plugins |
---|
4 | """ |
---|
5 | import os |
---|
6 | import wx |
---|
7 | import wx.html as html |
---|
8 | from wx.lib.splitter import MultiSplitterWindow |
---|
9 | from sans.guiframe import get_media_path |
---|
10 | |
---|
11 | class HelpWindow(wx.Frame): |
---|
12 | """ |
---|
13 | """ |
---|
14 | def __init__(self, parent, title='DataLoader Help', pageToOpen=None): |
---|
15 | wx.Frame.__init__(self, parent, title, size=(700, 450)) |
---|
16 | """ |
---|
17 | contains help info |
---|
18 | """ |
---|
19 | self.SetTitle('DataLoader Help') |
---|
20 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
21 | rpanel = wx.Panel(splitter, -1) |
---|
22 | lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) |
---|
23 | |
---|
24 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
25 | header = wx.Panel(rpanel, -1) |
---|
26 | header.SetBackgroundColour('#6666FF') |
---|
27 | header.SetForegroundColour('WHITE') |
---|
28 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
29 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
30 | font = st.GetFont() |
---|
31 | font.SetPointSize(10) |
---|
32 | st.SetFont(font) |
---|
33 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
34 | header.SetSizer(hbox) |
---|
35 | vbox.Add(header, 0, wx.EXPAND) |
---|
36 | |
---|
37 | vboxl = wx.BoxSizer(wx.VERTICAL) |
---|
38 | headerl = wx.Panel(lpanel, -1, size=(-1, 20)) |
---|
39 | |
---|
40 | headerl.SetBackgroundColour('#6666FF') |
---|
41 | headerl.SetForegroundColour('WHITE') |
---|
42 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
43 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
44 | fontl = lst.GetFont() |
---|
45 | fontl.SetPointSize(10) |
---|
46 | lst.SetFont(fontl) |
---|
47 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
48 | headerl.SetSizer(hboxl) |
---|
49 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
50 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
51 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, |
---|
52 | size=(500,-1)) |
---|
53 | |
---|
54 | self.path = get_media_path(media='media') |
---|
55 | page1 = """<html> |
---|
56 | <body> |
---|
57 | <p>Select topic on Menu</p> |
---|
58 | </body> |
---|
59 | </html>""" |
---|
60 | self.rhelp.SetPage(page1) |
---|
61 | page = """<html> |
---|
62 | <body> |
---|
63 | <ul> |
---|
64 | <li><a href ="data_explorer_help.html" |
---|
65 | target ="showframe">Data Explorer</a><br></li> |
---|
66 | </ul> |
---|
67 | </body> |
---|
68 | </html>""" |
---|
69 | |
---|
70 | self.lhelp.SetPage(page) |
---|
71 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
72 | |
---|
73 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
74 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
75 | rpanel.SetSizer(vbox) |
---|
76 | lpanel.SetSizer(vboxl) |
---|
77 | lpanel.SetFocus() |
---|
78 | |
---|
79 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
80 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
81 | splitter.AppendWindow(lpanel, 200) |
---|
82 | splitter.AppendWindow(rpanel) |
---|
83 | self.SetSizer(vbox1) |
---|
84 | |
---|
85 | self.Centre() |
---|
86 | self.Show(True) |
---|
87 | |
---|
88 | def OnLinkClicked(self, event): |
---|
89 | """ |
---|
90 | Function to diplay html page related to the hyperlinktext selected |
---|
91 | """ |
---|
92 | link = event.GetLinkInfo().GetHref() |
---|
93 | link = os.path.join(self.path, link) |
---|
94 | self.rhelp.LoadPage(link) |
---|
95 | |
---|
96 | |
---|
97 | class ViewApp(wx.App): |
---|
98 | def OnInit(self): |
---|
99 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
100 | frame.Show(True) |
---|
101 | self.SetTopWindow(frame) |
---|
102 | return True |
---|
103 | |
---|
104 | if __name__ == "__main__": |
---|
105 | app = ViewApp(0) |
---|
106 | app.MainLoop() |
---|