File: help.py

package info (click to toggle)
pype 2.9.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,200 kB
  • ctags: 1,468
  • sloc: python: 13,860; makefile: 8; sh: 7
file content (60 lines) | stat: -rw-r--r-- 1,787 bytes parent folder | download | duplicates (2)
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

'''
This software is licensed under the GPL (GNU General Public License) version 2
as it appears here: http://www.gnu.org/copyleft/gpl.html
It is also included with this archive as `gpl.txt <gpl.txt>`_.
'''


import wx
import wx.html as html
import sys
import os
import webbrowser

a = _pype.runpath + '/readme.html'

class MyHtmlWindow(html.HtmlWindow):
    def __init__(self, parent):
        html.HtmlWindow.__init__(self, parent,
            style=wx.NO_FULL_REPAINT_ON_RESIZE|wx.SUNKEN_BORDER)
        if "gtk2" in wx.PlatformInfo:
            self.SetStandardFonts()
        wx.CallAfter(self.LoadPage, a)
        
    def OnLinkClicked(self, link):
        a = link.GetHref()
        if a.startswith('#'):
            self.base_OnLinkClicked(link)
        else:
            webbrowser.open(a)
    
    def LoadPage(self, fn):
        self.SetPage(open(fn).read().replace('; charset=utf-8', ''))

class HtmlHelpDialog(wx.Dialog):
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, title="PyPE Help",
            style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, pos=(0,0))
        
        w, h = parent.GetSizeTuple()
        self.SetSize((3*w//4, 3*h//4))
        self.CentreOnParent()
        
        p = self
        s = wx.BoxSizer(wx.VERTICAL)
        
        self.html = MyHtmlWindow(p)
        
        s.Add(self.html, 1, wx.EXPAND|wx.ALL, 5)
        
        s2 = wx.BoxSizer(wx.HORIZONTAL)
        s2.Add(wx.StaticText(p, -1, ""), 1, wx.EXPAND)
        s2.Add(wx.Button(p, wx.ID_OK, "OK"), 0, wx.EXPAND)
        s2.Add(wx.StaticText(p, -1, ""), 1, wx.EXPAND)
        
        s.Add(s2, 0, wx.EXPAND|wx.ALL, 5)
        
        p.SetSizer(s)
        p.SetAutoLayout(1)
        p.Layout()