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
|
import wx
import wx.html as html
import sys
import os
import webbrowser
a = sys.modules['configuration'].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()
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)
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)
if "gtk2" in wx.PlatformInfo:
self.html.SetStandardFonts()
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()
wx.CallAfter(self.html.LoadPage, a)
|