article

Friday, June 10, 2016

wxpython widgets wx.html Help window

wxpython widgets wx.html Help window

 wx.html.HtmlWindow to provide help in our application. We can create a standalone window or we can create a window that is going to be a part of the application. The following script will create a help window using the latter idea.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import wx
import wx.html as html
 
class HelpWindow(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(570, 400))
 
        toolbar = self.CreateToolBar()
        toolbar.AddLabelTool(1, 'Exit', wx.Bitmap('img/quit.png'))
        toolbar.AddLabelTool(2, 'Help', wx.Bitmap('img/help.png'))
        toolbar.Realize()
 
        self.splitter = wx.SplitterWindow(self, -1)
        self.panelLeft = wx.Panel(self.splitter, -1, style=wx.BORDER_SUNKEN)
 
        self.panelRight = wx.Panel(self.splitter, -1)
        vbox2 = wx.BoxSizer(wx.VERTICAL)
        header = wx.Panel(self.panelRight, -1, size=(-1, 20))
        header.SetBackgroundColour('#6f6a59')
        header.SetForegroundColour('WHITE')
        hbox = wx.BoxSizer(wx.HORIZONTAL)
 
        st = wx.StaticText(header, -1, 'Help', (5, 5))
        font = st.GetFont()
        font.SetPointSize(9)
        st.SetFont(font)
        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
 
        close = wx.BitmapButton(header, -1, wx.Bitmap('img/quit.png', wx.BITMAP_TYPE_PNG),
  style=wx.NO_BORDER)
        close.SetBackgroundColour('#6f6a59')
        hbox.Add(close, 0)
        header.SetSizer(hbox)
 
        vbox2.Add(header, 0, wx.EXPAND)
 
        help = html.HtmlWindow(self.panelRight, -1, style=wx.NO_BORDER)
        help.LoadPage('help.html')
        vbox2.Add(help, 1, wx.EXPAND)
        self.panelRight.SetSizer(vbox2)
        self.panelLeft.SetFocus()
 
        self.splitter.SplitVertically(self.panelLeft, self.panelRight)
        self.splitter.Unsplit()
 
        self.Bind(wx.EVT_BUTTON, self.CloseHelp, id=close.GetId())
        self.Bind(wx.EVT_TOOL, self.OnClose, id=1)
        self.Bind(wx.EVT_TOOL, self.OnHelp, id=2)
 
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)
 
        self.CreateStatusBar()
 
        self.Centre()
        self.Show(True)
 
    def OnClose(self, event):
        self.Close()
 
    def OnHelp(self, event):
        self.splitter.SplitVertically(self.panelLeft, self.panelRight)
        self.panelLeft.SetFocus()
 
    def CloseHelp(self, event):
        self.splitter.Unsplit()
        self.panelLeft.SetFocus()
 
    def OnKeyPressed(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_F1:
            self.splitter.SplitVertically(self.panelLeft, self.panelRight)
            self.panelLeft.SetFocus()
 
 
app = wx.App()
HelpWindow(None, -1, 'HelpWindow')
app.MainLoop()
help.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<h4>Table of Contents</h4>
 
<ul>
<li><a href="#basic">Basic statistics</a></li>
<li><a href="#advanced">Advanced statistics</a></li>
<li><a href="#intro">Introducing Newt</a></li>
<li><a href="#charts">Working with charts</a></li>
<li><a href="#pred">Predicting values</a></li>
<li><a href="#neural">Neural networks</a></li>
<li><a href="#glos">Glossary</a></li>
</ul>
 
<p>
<a name="basic">
</a></p><h6><a name="basic">Basic Statistics</a></h6><a name="basic">
Overview of elementary concepts in statistics.
Variables. Correlation. Measurement scales. Statistical significance.
Distributions. Normality assumption.
</a>
<p></p>
 
<p>
<a name="advanced">
</a></p><h6><a name="advanced">Advanced Statistics</a></h6><a name="advanced">
Overview of advanced concepts in statistics. Anova. Linear regression.
Estimation and  hypothesis testing.
Error terms.
</a>
<p></p>
 
<p>
<a name="intro">
</a></p><h6><a name="intro">Introducing Newt</a></h6><a name="intro">
Introducing the basic functionality of the Newt application. Creating sheets.
Charts. Menus and Toolbars. Importing data. Saving data in various formats.
Exporting data. Shortcuts. List of methods.
</a>
<p></p>
 
<p>
<a name="charts">
</a></p><h6><a name="charts">Charts</a></h6><a name="charts">
Working with charts. 2D charts. 3D charts. Bar, line, box, pie, range charts.
Scatterplots. Histograms.
</a>
<p></p>
 
<p>
<a name="pred">
</a></p><h6><a name="pred">Predicting values</a></h6><a name="pred">
Time series and forecasting. Trend Analysis. Seasonality. Moving averages.
Univariate methods. Multivariate methods. Holt-Winters smoothing.
Exponential smoothing. ARIMA. Fourier analysis.
</a>
<p></p>
 
<p>
<a name="neural">
</a></p><h6><a name="neural">Neural networks</a></h6><a name="neural">
Overview of neural networks. Biology behind neural networks.
Basic artificial Model. Training. Preprocessing. Postprocessing.
Types of neural networks.
</a>
<p></p>
 
<p>
<a name="glos">
</a></p><h6><a name="glos">Glossary</a></h6><a name="glos">
Terms and definitions in statistics.
</a>
<p></p>

Related Post