Python wx 模块,html() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用wx.html()

项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: help_window.__init__
        kwds["style"] = wx.MAXIMIZE | wx.CLOSE_BOX | wx.THICK_FRAME|wx.CAPTION
        wx.Dialog.__init__(self, *args, **kwds)
        self.window_1 = wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_3D | wx.SP_BORDER)
        self.window_1_pane_left = wx.Panel(self.window_1, wx.ID_ANY)
        self.html_left = html.HtmlWindow(self.window_1_pane_left, wx.ID_ANY, size=(1, 1))
        self.window_1_pane_right = wx.Panel(self.window_1, wx.ID_ANY)
        self.html_right = html.HtmlWindow(self.window_1_pane_right, wx.ID_ANY, size=(1, 1))

        #self.Bind(wx.EVT_COself.on_hyperlink,self.html_left)
        self.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.on_hyperlink,self.html_left)
        #self.Bind(wx.EVT_SIZE,self.on_resize)

        self.__set_properties()
        self.__do_layout()
        #self.on_resize(None)
        self.load_htmlpage()
        # end wxGlade
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self, parent):

        wx.Frame.__init__(self, parent, wx.ID_ANY, title="About", size=(400,400))

        html = wxHTML(self)

        html.SetPage(
            ''

            "<h2>About the About Tutorial</h2>"

            "<p>This about box is for demo purposes only. It was created in June 2006 "

            "by Mike Driscoll.</p>"

            "<p><b>Software used in making this demo:</h3></p>"

            '<p><b><a href="http://www.python.org">Python 2.7 / 3.5</a></b></p>'

            '<p><b><a href="http://www.wxpython.org">wxPython 3.0.2.0 / Phoenix</a></b></p>'
        )
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self, parent):

        wx.Frame.__init__(self, parent, wx.ID_ANY, title="About", size=(400,400))

        html = wxHTML(self)

        html.SetPage(
            ''

            "<h2>About the About Tutorial</h2>"

            "<p>This about box is for demo purposes only. It was created in June 2006"

            "by Mike Driscoll.</p>"

            "<p><b>Software used in making this demo:</h3></p>"

            '<p><b><a href="http://www.python.org">Python 2.4</a></b></p>'

            '<p><b><a href="http://www.wxpython.org">wxPython 2.8</a></b></p>'
        )
项目:nodemcu-pyflasher    作者:marcelstoer    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Dialog.__init__(self, parent, wx.ID_ANY, "About NodeMCU PyFlasher")
        html = HtmlWindow(self, wx.ID_ANY, size=(420, -1))
        if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo:
            html.SetStandardFonts()
        txt = self.text.format(self._get_bundle_dir(), __version__)
        html.SetPage(txt)
        ir = html.GetInternalRepresentation()
        html.SetSize((ir.GetWidth() + 25, ir.GetHeight() + 25))
        self.SetClientSize(html.GetSize())
        self.CentreOnParent(wx.BOTH)
项目:nodemcu-pyflasher    作者:marcelstoer    | 项目源码 | 文件源码
def _get_bundle_dir(self):
        # set by PyInstaller, see http://pyinstaller.readthedocs.io/en/v3.2/runtime-information.html
        if getattr(sys, 'frozen', False):
            return sys._MEIPASS
        else:
            return os.path.dirname(os.path.abspath(__file__))
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def InitUI(self):
        self.panel = wx.Panel(self, wx.ID_ANY)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.html = help = wx.html.HtmlWindow(self.panel, -1, style=wx.NO_BORDER)

        # http://wxpython-users.1045709.n5.nabble.com/Open-a-URL-with-the-default-browser-from-an-HtmlWindow-td2326349.html
        # Bind LINK Click Event to own Function
        help.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)

        #import codecs
        #file = codecs.open(self.help, "r", "utf-8")
        try:
            file = open(self.help, "r")
        except IOError:
            dlgmsg = u"File not found: \"{}\"".format(self.help)
            dlg = wx.MessageDialog(None, dlgmsg, "WPKG-GP Client", wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            self.Destroy()
        else:
            test = file.read().decode("utf-8")
            html = markdown2.markdown(test, extras=["tables"])
            html = '<body bgcolor="#f0f0f5">' + html
            #print html
            help.SetPage(html)
            sizer.Add(help, 1, wx.EXPAND)
            self.panel.SetSizerAndFit(sizer)
            self.Bind(wx.EVT_CLOSE, self.OnClose)
项目:wpkg-gp-client    作者:sonicnkt    | 项目源码 | 文件源码
def OnLinkClicked(self, link):
        # If Link is an anchor link let the html window do its job
        # If it is not an anchor link let the default browser open the page
        href = link.GetLinkInfo().GetHref()
        anchor = href[1:]
        if href.startswith('#'):
            self.html.ScrollToAnchor(anchor)
        else:
            wx.BeginBusyCursor()
            webbrowser.open(href)
            wx.EndBusyCursor()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
        if event == HtmlWindowUrlClick:
            self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler)
        else:
            wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def _init_ctrls(self, prnt):
            wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame',
                              parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616),
                              style=wx.DEFAULT_FRAME_STYLE, title='')
            self.SetIcon(prnt.icon)
            self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)

            self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT,
                                                  name='HtmlContent', parent=self, pos=wx.Point(0, 0),
                                                  size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO | wx.html.HW_NO_SELECTION)
            self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick)
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def feed_html(self,html,first_page=False):


        self.feed(html)
项目:smartschool    作者:asifkodur    | 项目源码 | 文件源码
def load_htmlpage(self):
        self.html_left.LoadPage('docs/docs.html')
        self.html_right.LoadPage('docs/docs.html')
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def __init__(self, title='Snapshot Printer'):
        wx.Frame.__init__(self, None, title=title, 
                          size=(650,400))

        self.panel = wx.Panel(self)
        self.printer = HtmlEasyPrinting(
            name='Printing', parentWindow=None)

        self.html = HtmlWindow(self.panel)
        self.html.SetRelatedFrame(self, self.GetTitle())

        if not os.path.exists('screenshot.htm'):
            self.createHtml()
        self.html.LoadPage('screenshot.htm')

        pageSetupBtn = wx.Button(self.panel, label='Page Setup')
        printBtn = wx.Button(self.panel, label='Print')
        cancelBtn = wx.Button(self.panel, label='Cancel')

        self.Bind(wx.EVT_BUTTON, self.onSetup, pageSetupBtn)
        self.Bind(wx.EVT_BUTTON, self.onPrint, printBtn)
        self.Bind(wx.EVT_BUTTON, self.onCancel, cancelBtn)

        sizer = wx.BoxSizer(wx.VERTICAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)

        sizer.Add(self.html, 1, wx.GROW)
        btnSizer.Add(pageSetupBtn, 0, wx.ALL, 5)
        btnSizer.Add(printBtn, 0, wx.ALL, 5)
        btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
        sizer.Add(btnSizer)

        self.panel.SetSizer(sizer)
        self.panel.SetAutoLayout(True)
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def createHtml(self):
        '''
        Creates an html file in the home directory of the application
        that contains the information to display the snapshot
        '''
        print('creating html...')

        html = '''<html>\n<body>\n<center>
        <img src=myImage.png width=516 height=314>
        </center>\n</body>\n</html>'''
        with open('screenshot.htm', 'w') as fobj:
            fobj.write(html)
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def sendToPrinter(self):
        self.printer.GetPrintData().SetPaperId(wx.PAPER_LETTER)
        self.printer.PrintFile(self.html.GetOpenedPage())