1 | #!/usr/bin/python |
---|
2 | |
---|
3 | import wx |
---|
4 | import wx.html as html |
---|
5 | from wx.lib.splitter import MultiSplitterWindow |
---|
6 | import os |
---|
7 | |
---|
8 | |
---|
9 | class HelpWindow(wx.Frame): |
---|
10 | """ |
---|
11 | """ |
---|
12 | def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): |
---|
13 | wx.Frame.__init__(self, parent, id, title, size=(850, 500)) |
---|
14 | """ |
---|
15 | contains help info |
---|
16 | """ |
---|
17 | |
---|
18 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
19 | rpanel = wx.Panel(splitter, -1) |
---|
20 | lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN) |
---|
21 | |
---|
22 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
23 | header = wx.Panel(rpanel, -1) |
---|
24 | header.SetBackgroundColour('#6666FF') |
---|
25 | header.SetForegroundColour('WHITE') |
---|
26 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
27 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
28 | font = st.GetFont() |
---|
29 | font.SetPointSize(10) |
---|
30 | st.SetFont(font) |
---|
31 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
32 | header.SetSizer(hbox) |
---|
33 | vbox.Add(header, 0, wx.EXPAND) |
---|
34 | |
---|
35 | vboxl= wx.BoxSizer(wx.VERTICAL) |
---|
36 | headerl = wx.Panel(lpanel, -1, size=(-1, 20)) |
---|
37 | |
---|
38 | headerl.SetBackgroundColour('#6666FF') |
---|
39 | headerl.SetForegroundColour('WHITE') |
---|
40 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
41 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
42 | fontl = lst.GetFont() |
---|
43 | fontl.SetPointSize(10) |
---|
44 | lst.SetFont(fontl) |
---|
45 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
46 | headerl.SetSizer(hboxl) |
---|
47 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
48 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
49 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1)) |
---|
50 | |
---|
51 | import sans.models as models |
---|
52 | # get the media path |
---|
53 | path = models.get_data_path(media='media') |
---|
54 | self.path = os.path.join(path,"model_functions.html") |
---|
55 | |
---|
56 | page1="""<html> |
---|
57 | <body> |
---|
58 | <p>Select topic on Menu</p> |
---|
59 | </body> |
---|
60 | </html>""" |
---|
61 | page="""<html> |
---|
62 | <body> |
---|
63 | <ul> |
---|
64 | <li><a href ="media/change_scale_help.html" target ="showframe">Change Scale</a><br></li> |
---|
65 | <li><a href ="media/reset_Graph_help.html" target ="showframe">Graph Help</a><br></li> |
---|
66 | <li><a href ="media/status_bar_help.html" target ="showframe">Status Bar Help</a><br></li> |
---|
67 | <li><a href ="media/load_data_help.html" target ="showframe">Load a File</a><br></li> |
---|
68 | <li><a href ="media/simultaneous_fit_help.html" target ="showframe">Simultaneous Fit</a><br></li> |
---|
69 | <li><a href ="media/single_fit_help.html" target ="showframe">Single Fit</a><br></li> |
---|
70 | <li><a href ="media/model_use_help.html" target ="showframe">Visualize Model</a><br></li> |
---|
71 | <li><a href ="media/averaging_help.html" target ="showframe">Data Averaging</a><br></li> |
---|
72 | <li><a href ="%s" target ="showframe">Model Functions</a><br></li> |
---|
73 | </ul> |
---|
74 | </body> |
---|
75 | </html>""" % self.path |
---|
76 | |
---|
77 | self.rhelp.SetPage(page1) |
---|
78 | self.lhelp.SetPage(page) |
---|
79 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked ) |
---|
80 | |
---|
81 | #open the help frame a the current page |
---|
82 | if pageToOpen!= None: |
---|
83 | self.rhelp.LoadPage(str( pageToOpen)) |
---|
84 | |
---|
85 | vbox.Add(self.rhelp,1, wx.EXPAND) |
---|
86 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
87 | rpanel.SetSizer(vbox) |
---|
88 | lpanel.SetSizer(vboxl) |
---|
89 | lpanel.SetFocus() |
---|
90 | |
---|
91 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
92 | vbox1.Add(splitter,1,wx.EXPAND) |
---|
93 | splitter.AppendWindow(lpanel, 200) |
---|
94 | splitter.AppendWindow(rpanel) |
---|
95 | self.SetSizer(vbox1) |
---|
96 | |
---|
97 | self.Centre() |
---|
98 | self.Show(True) |
---|
99 | |
---|
100 | def OnButtonClicked(self, event): |
---|
101 | """ |
---|
102 | Function to diplay html page related to the hyperlinktext selected |
---|
103 | """ |
---|
104 | |
---|
105 | self.rhelp.LoadPage(self.path) |
---|
106 | |
---|
107 | def OnLinkClicked(self, event): |
---|
108 | """ |
---|
109 | Function to diplay html page related to the hyperlinktext selected |
---|
110 | """ |
---|
111 | link= event.GetLinkInfo().GetHref() |
---|
112 | self.rhelp.LoadPage(link) |
---|
113 | """ |
---|
114 | Example: :: |
---|
115 | |
---|
116 | class ViewApp(wx.App): |
---|
117 | def OnInit(self): |
---|
118 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
119 | frame.Show(True) |
---|
120 | self.SetTopWindow(frame) |
---|
121 | |
---|
122 | return True |
---|
123 | |
---|
124 | |
---|
125 | if __name__ == "__main__": |
---|
126 | app = ViewApp(0) |
---|
127 | app.MainLoop() |
---|
128 | |
---|
129 | """ |
---|