2
# Programmer: Eur Ing Christopher Thoday.
3
# Copyright: assigned to the DrPython project
7
"""This module provides a browser for displaying HTML files composed in
8
the DrPython text editor. Links are displayed within separate pages
9
within the browser. The tab name for the page is the HTML title if given,
10
else it is the file name."""
16
if href[0:5] != "http:":
17
if not os.path.exists(href):
18
href = os.path.normpath(os.path.join(dir, href))
19
if not os.path.exists(href):
20
wx.MessageBox("File does not exist: " + href, "DrPython HTML Browser")
23
note.SetSelection(history[href])
25
np = note.GetPageCount()
27
page = HtmlPage(note, -1)
28
note.AddPage(page, "", True)
30
title = page.GetOpenedPageTitle()
31
(fname, ext) = os.path.splitext(title)
32
if ext[0:4] == ".htm" or ext[0:5] == ".html":
34
note.SetPageText(np, title)
36
class HtmlPage(wx.html.HtmlWindow):
37
def __init__(self, parent, id):
38
wx.html.HtmlWindow.__init__(self, parent, id,
39
style=wx.NO_FULL_REPAINT_ON_RESIZE)
40
if "gtk2" in wx.PlatformInfo: self.SetStandardFonts()
42
def OnLinkClicked(self, link):
47
class HtmlBrowser(wx.Dialog):
48
def __init__(self, parent, file, title):
50
dir = os.path.dirname(file)
51
wx.Dialog.__init__(self, parent, -1, title, size=(500, 600), style=wx.DEFAULT_DIALOG_STYLE | wx.THICK_FRAME)
52
note = wx.Notebook(self, -1)
56
#else nothing is displayed
57
event = wx.SizeEvent()
58
self.GetEventHandler().ProcessEvent(event)
61
def ShowHtmlFile(parent, file, title=""):
64
d = HtmlBrowser(parent, file, title)
b'\\ No newline at end of file'