1 | #!/usr/bin/python |
---|
2 | import wx |
---|
3 | import wx.html as html |
---|
4 | from wx.lib.splitter import MultiSplitterWindow |
---|
5 | import os |
---|
6 | |
---|
7 | |
---|
8 | class HelpDialog(wx.Dialog): |
---|
9 | """ |
---|
10 | """ |
---|
11 | def __init__(self, parent, id): |
---|
12 | """ |
---|
13 | """ |
---|
14 | wx.Dialog.__init__(self, parent, id, size=(400, 420)) |
---|
15 | self.SetTitle("Invariant help") |
---|
16 | |
---|
17 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
18 | |
---|
19 | explanation = help() |
---|
20 | |
---|
21 | label_explain = wx.StaticText(self, -1, explanation, size=(350, 320)) |
---|
22 | |
---|
23 | vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15) |
---|
24 | |
---|
25 | |
---|
26 | static_line = wx.StaticLine(self, -1) |
---|
27 | vbox.Add(static_line, 0, wx.EXPAND, 0) |
---|
28 | |
---|
29 | button_OK = wx.Button(self, wx.ID_OK, "OK") |
---|
30 | |
---|
31 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
32 | sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
33 | sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
34 | vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) |
---|
35 | |
---|
36 | self.SetSizer(vbox) |
---|
37 | self.SetAutoLayout(True) |
---|
38 | |
---|
39 | self.Layout() |
---|
40 | self.Centre() |
---|
41 | |
---|
42 | class HelpWindow(wx.Frame): |
---|
43 | """ |
---|
44 | """ |
---|
45 | def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): |
---|
46 | wx.Frame.__init__(self, parent, id, title, size=(820, 450)) |
---|
47 | """ |
---|
48 | contains help info |
---|
49 | """ |
---|
50 | self.SetTitle("Invariant Help") |
---|
51 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
52 | rpanel = wx.Panel(splitter, -1) |
---|
53 | lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) |
---|
54 | |
---|
55 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
56 | header = wx.Panel(rpanel, -1) |
---|
57 | header.SetBackgroundColour('#6666FF') |
---|
58 | header.SetForegroundColour('WHITE') |
---|
59 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
---|
60 | st = wx.StaticText(header, -1, 'Contents', (5, 5)) |
---|
61 | font = st.GetFont() |
---|
62 | font.SetPointSize(10) |
---|
63 | st.SetFont(font) |
---|
64 | hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
65 | header.SetSizer(hbox) |
---|
66 | vbox.Add(header, 0, wx.EXPAND) |
---|
67 | |
---|
68 | vboxl = wx.BoxSizer(wx.VERTICAL) |
---|
69 | headerl = wx.Panel(lpanel, -1, size=(-1, 20)) |
---|
70 | |
---|
71 | headerl.SetBackgroundColour('#6666FF') |
---|
72 | headerl.SetForegroundColour('WHITE') |
---|
73 | hboxl = wx.BoxSizer(wx.HORIZONTAL) |
---|
74 | lst = wx.StaticText(headerl, -1, 'Menu', (5, 5)) |
---|
75 | fontl = lst.GetFont() |
---|
76 | fontl.SetPointSize(10) |
---|
77 | lst.SetFont(fontl) |
---|
78 | hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5) |
---|
79 | headerl.SetSizer(hboxl) |
---|
80 | vboxl.Add(headerl, 0, wx.EXPAND) |
---|
81 | self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER) |
---|
82 | self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, |
---|
83 | size=(500, -1)) |
---|
84 | import sans.perspectives.invariant as invariant |
---|
85 | path = invariant.get_data_path(media='media') |
---|
86 | self.path = os.path.join(path,"invariant_help.html") |
---|
87 | |
---|
88 | self.rhelp.LoadPage(self.path) |
---|
89 | page = """<html> |
---|
90 | <body> |
---|
91 | <ul> |
---|
92 | <li><a href ="%s" target ="showframe">Invariant</a><br></li> |
---|
93 | </ul> |
---|
94 | </body> |
---|
95 | </html>""" % self.path |
---|
96 | |
---|
97 | self.lhelp.SetPage(page) |
---|
98 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
99 | |
---|
100 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
101 | vboxl.Add(self.lhelp, 1, wx.EXPAND) |
---|
102 | rpanel.SetSizer(vbox) |
---|
103 | lpanel.SetSizer(vboxl) |
---|
104 | lpanel.SetFocus() |
---|
105 | |
---|
106 | vbox1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
107 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
108 | splitter.AppendWindow(lpanel, 200) |
---|
109 | splitter.AppendWindow(rpanel) |
---|
110 | self.SetSizer(vbox1) |
---|
111 | |
---|
112 | self.Centre() |
---|
113 | self.Show(True) |
---|
114 | |
---|
115 | |
---|
116 | def OnLinkClicked(self, event): |
---|
117 | """ |
---|
118 | Function to diplay html page related to the hyperlinktext selected |
---|
119 | """ |
---|
120 | self.rhelp.LoadPage(self.path) |
---|
121 | |
---|
122 | class ViewApp(wx.App): |
---|
123 | """ |
---|
124 | """ |
---|
125 | def OnInit(self): |
---|
126 | """ |
---|
127 | """ |
---|
128 | frame = HelpWindow(None, -1, 'HelpWindow') |
---|
129 | frame.Show(True) |
---|
130 | self.SetTopWindow(frame) |
---|
131 | |
---|
132 | return True |
---|
133 | |
---|
134 | |
---|
135 | if __name__ == "__main__": |
---|
136 | app = ViewApp(0) |
---|
137 | app.MainLoop() |
---|