import wx
import wx.html as html

class MainFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, -1, title)
        panel = MainPanel(self)

class AnHtmlWindow(html.HtmlWindow):
    def __init__(self, parent, id):
        txt_style = wx.VSCROLL|wx.HSCROLL|wx.TE_READONLY|wx.BORDER_SIMPLE
        html.HtmlWindow.__init__(self, parent, id, style=txt_style, size=(300, 150))
        if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo:
            self.SetStandardFonts()

    def OnLinkClicked(self, linkinfo):
        print('OnLinkClicked: %s\n' % linkinfo)
        super(MyHtmlWindow, self).OnLinkClicked(linkinfo)
        
    def OnCellClicked(self, cell, x, y, evt):
        print('OnCellClicked: %s, (%d %d)\n' % (cell, x, y))
        if isinstance(cell, html.HtmlWordCell):
            sel = html.HtmlSelection()
            self.log.WriteText('     %s\n' % cell.ConvertToText(sel))
        super(MyHtmlWindow, self).OnCellClicked(cell, x, y, evt)

class MainPanel(wx.Panel):
    def __init__(self, frame):
        wx.Panel.__init__(self, frame)

        self.html = AnHtmlWindow(self, -1)
        self.html.LoadPage('temphtm.htm')

app = wx.App()
frm = MainFrame(None, "Screen layout")
frm.Show()
app.MainLoop()