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