[f29a433] | 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): |
---|
[d7a39e5] | 9 | """ |
---|
| 10 | """ |
---|
[f29a433] | 11 | def __init__(self, parent, id): |
---|
[d7a39e5] | 12 | """ |
---|
| 13 | """ |
---|
[f29a433] | 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 | |
---|
[4a2b054] | 21 | label_explain = wx.StaticText(self, -1, explanation, size=(350, 320)) |
---|
[f29a433] | 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): |
---|
[d7a39e5] | 43 | """ |
---|
| 44 | """ |
---|
[f29a433] | 45 | def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None): |
---|
[1c779b6] | 46 | wx.Frame.__init__(self, parent, id, title, size=(820, 450)) |
---|
[f29a433] | 47 | """ |
---|
[d7a39e5] | 48 | contains help info |
---|
[f29a433] | 49 | """ |
---|
| 50 | |
---|
| 51 | splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
---|
| 52 | rpanel = wx.Panel(splitter, -1) |
---|
[4a2b054] | 53 | lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) |
---|
[f29a433] | 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 | |
---|
[4a2b054] | 68 | vboxl = wx.BoxSizer(wx.VERTICAL) |
---|
[f29a433] | 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, |
---|
[4a2b054] | 83 | size=(500, -1)) |
---|
[698a734] | 84 | import sans.perspectives.invariant as invariant |
---|
| 85 | path = invariant.get_data_path(media='media') |
---|
[4a2b054] | 86 | self.path = os.path.join(path,"invariant_help.html") |
---|
[698a734] | 87 | |
---|
[f29a433] | 88 | self.rhelp.LoadPage(self.path) |
---|
[4a2b054] | 89 | page = """<html> |
---|
[f29a433] | 90 | <body> |
---|
| 91 | <ul> |
---|
[cf9b6950] | 92 | <li><a href ="%s" target ="showframe">Invariant</a><br></li> |
---|
[f29a433] | 93 | </ul> |
---|
| 94 | </body> |
---|
[4a2b054] | 95 | </html>""" % self.path |
---|
[f29a433] | 96 | |
---|
| 97 | self.lhelp.SetPage(page) |
---|
[4a2b054] | 98 | self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked) |
---|
[f29a433] | 99 | |
---|
[4a2b054] | 100 | vbox.Add(self.rhelp, 1, wx.EXPAND) |
---|
[f29a433] | 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) |
---|
[4a2b054] | 107 | vbox1.Add(splitter, 1, wx.EXPAND) |
---|
[f29a433] | 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 | """ |
---|
[d7a39e5] | 118 | Function to diplay html page related to the hyperlinktext selected |
---|
[f29a433] | 119 | """ |
---|
| 120 | self.rhelp.LoadPage(self.path) |
---|
| 121 | |
---|
| 122 | class ViewApp(wx.App): |
---|
[4a2b054] | 123 | """ |
---|
| 124 | """ |
---|
[f29a433] | 125 | def OnInit(self): |
---|
[4a2b054] | 126 | """ |
---|
| 127 | """ |
---|
[f29a433] | 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() |
---|