Why does not my wx.html.HtmlWindow work?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • liqfemail@gmail.com

    #1

    Why does not my wx.html.HtmlWindow work?

    Below are my source code:

    import wx
    import wx.html

    class MyHtmlFrame(wx. Frame):

    def __init__(self, parent, title):
    wx.Frame.__init __(self, parent, -1, title, size=(600,400))
    html = wx.html.HtmlWin dow (self)
    if "gtk2" in wx.PlatformInfo :
    html.SetStandar dFonts()
    html.LoadPage(" http://www.pythonthrea ds.com/articles/python/incorporating-into-wxpython-part-1.html")

    app = wx.PySimpleApp( )
    frm = MyHtmlFrame(Non e, "Simple HTML Browser")
    frm.Show()
    app.MainLoop()

    It is just an example in the book "wxPython in action". But every time
    when I try to get it run, my CPU is fully occupied, and there is no
    frame that comes into existence. Why?

  • =?ISO-8859-15?Q?Thomas_Kr=FCger?=

    #2
    Re: Why does not my wx.html.HtmlWin dow work?

    liqfemail@gmail .com schrieb:
    html.LoadPage(" http://www.pythonthrea ds.com/articles/python/incorporating-into-wxpython-part-1.html")
    Quickshot: There's a space at the start of your URI.

    Thomas

    Comment

    • liqfemail@gmail.com

      #3
      Re: Why does not my wx.html.HtmlWin dow work?

      On 4ÔÂ8ÈÕ, ÏÂÎç2ʱ29·Ö, Thomas Kr¨¹ger <newsgro....@no spam.nowire.org wrote:
      liqfem...@gmail .com schrieb:
      >
      html.LoadPage(" http://www.pythonthrea ds.com/articles/python/incorporating-into-wxpyt...")
      >
      Quickshot: There's a space at the start of your URI.
      >
      Thomas
      It seems it's not the problem.
      In my final program there is no such mistake.

      Comment

      • Rob Williscroft

        #4
        Re: Why does not my wx.html.HtmlWin dow work?

        liqfemail@gmail .com wrote in
        news:1176003505 .794328.62170@n 76g2000hsh.goog legroups.com in
        comp.lang.pytho n:
        Below are my source code:
        >
        import wx
        import wx.html
        >
        class MyHtmlFrame(wx. Frame):
        >
        def __init__(self, parent, title):
        wx.Frame.__init __(self, parent, -1, title, size=(600,400))
        html = wx.html.HtmlWin dow (self)
        if "gtk2" in wx.PlatformInfo :
        html.SetStandar dFonts()
        html.LoadPage("

        -wxpython-part-1.html")
        >
        app = wx.PySimpleApp( )
        frm = MyHtmlFrame(Non e, "Simple HTML Browser")
        frm.Show()
        app.MainLoop()
        >
        It is just an example in the book "wxPython in action". But every time
        when I try to get it run, my CPU is fully occupied, and there is no
        frame that comes into existence. Why?
        >
        I think your problem is that you call LoadPage before app.MainLoop() is
        called, IOW you need to call LoadPage in an event handler:

        import wx
        import wx.html

        class MyHtmlFrame(wx. Frame):

        HOME = "http://www.google.co.u k"

        def __init__(self, parent, title):
        wx.Frame.__init __(self, parent, -1, title, size=(600,400))
        self.html = wx.html.HtmlWin dow (self)
        if "gtk2" in wx.PlatformInfo :
        self.html.SetSt andardFonts()
        self.done_show = False
        wx.EVT_IDLE( self, self.OnShow )
        self.html.SetPa ge(
        "<a href='%s'>Loadi ng ...</a>" % self.HOME
        )

        def OnShow( self, event ):
        if self.done_show:
        return
        self.done_show = True
        self.html.LoadP age( self.HOME )

        app = wx.PySimpleApp( )
        frm = MyHtmlFrame(Non e, "Simple HTML Browser")
        frm.Show()
        app.MainLoop()

        Note: the URL you loading takes ages to show, which is why I
        use: http://www.google.co.uk above.

        Rob.
        --

        Comment

        • liqfemail@gmail.com

          #5
          Re: Why does not my wx.html.HtmlWin dow work?

          On Apr 9, 1:01 am, Rob Williscroft <r...@freenet.c o.ukwrote:
          liqfem...@gmail .com wrote innews:11760035 05.794328.62170 @n76g2000hsh.go oglegroups.comi n
          comp.lang.pytho n:
          >
          >
          >
          Below are my source code:
          >
          import wx
          import wx.html
          >
          class MyHtmlFrame(wx. Frame):
          >
          def __init__(self, parent, title):
          wx.Frame.__init __(self, parent, -1, title, size=(600,400))
          html = wx.html.HtmlWin dow (self)
          if "gtk2" in wx.PlatformInfo :
          html.SetStandar dFonts()
          html.LoadPage("

          -wxpython-part-1.html")
          >
          app = wx.PySimpleApp( )
          frm = MyHtmlFrame(Non e, "Simple HTML Browser")
          frm.Show()
          app.MainLoop()
          >
          It is just an example in the book "wxPython in action". But every time
          when I try to get it run, my CPU is fully occupied, and there is no
          frame that comes into existence. Why?
          >
          I think your problem is that you call LoadPage before app.MainLoop() is
          called, IOW you need to call LoadPage in an event handler:
          >
          import wx
          import wx.html
          >
          class MyHtmlFrame(wx. Frame):
          >
          HOME = "http://www.google.co.u k"
          >
          def __init__(self, parent, title):
          wx.Frame.__init __(self, parent, -1, title, size=(600,400))
          self.html = wx.html.HtmlWin dow (self)
          if "gtk2" in wx.PlatformInfo :
          self.html.SetSt andardFonts()
          self.done_show = False
          wx.EVT_IDLE( self, self.OnShow )
          self.html.SetPa ge(
          "<a href='%s'>Loadi ng ...</a>" % self.HOME
          )
          >
          def OnShow( self, event ):
          if self.done_show:
          return
          self.done_show = True
          self.html.LoadP age( self.HOME )
          >
          app = wx.PySimpleApp( )
          frm = MyHtmlFrame(Non e, "Simple HTML Browser")
          frm.Show()
          app.MainLoop()
          >
          Note: the URL you loading takes ages to show, which is why I
          use:http://www.google.co.ukabove.
          >
          Rob.
          --http://www.victim-prime.dsl.pipex .com/

          To Rob Williscroft,

          It works when I call LoadPage() in any event handler, though I don't
          know the reason. I'll try to learn it.
          Thank you.
          And the example in the book "wxPython In Action" is wrong?

          Comment

          • kyosohma@gmail.com

            #6
            Re: Why does not my wx.html.HtmlWin dow work?

            On Apr 8, 8:31 pm, "liqfem...@gmai l.com" <liqfem...@gmai l.comwrote:
            On Apr 9, 1:01 am, Rob Williscroft <r...@freenet.c o.ukwrote:
            >
            >
            >
            liqfem...@gmail .com wrote innews:11760035 05.794328.62170 @n76g2000hsh.go oglegroups.comi n
            comp.lang.pytho n:
            >
            Below are my source code:
            >
            import wx
            import wx.html
            >
            class MyHtmlFrame(wx. Frame):
            >
            def __init__(self, parent, title):
            wx.Frame.__init __(self, parent, -1, title, size=(600,400))
            html = wx.html.HtmlWin dow (self)
            if "gtk2" in wx.PlatformInfo :
            html.SetStandar dFonts()
            html.LoadPage("

            -wxpython-part-1.html")
            >
            app = wx.PySimpleApp( )
            frm = MyHtmlFrame(Non e, "Simple HTML Browser")
            frm.Show()
            app.MainLoop()
            >
            It is just an example in the book "wxPython in action". But every time
            when I try to get it run, my CPU is fully occupied, and there is no
            frame that comes into existence. Why?
            >
            I think your problem is that you call LoadPage before app.MainLoop() is
            called, IOW you need to call LoadPage in an event handler:
            >
            import wx
            import wx.html
            >
            class MyHtmlFrame(wx. Frame):
            >
            HOME = "http://www.google.co.u k"
            >
            def __init__(self, parent, title):
            wx.Frame.__init __(self, parent, -1, title, size=(600,400))
            self.html = wx.html.HtmlWin dow (self)
            if "gtk2" in wx.PlatformInfo :
            self.html.SetSt andardFonts()
            self.done_show = False
            wx.EVT_IDLE( self, self.OnShow )
            self.html.SetPa ge(
            "<a href='%s'>Loadi ng ...</a>" % self.HOME
            )
            >
            def OnShow( self, event ):
            if self.done_show:
            return
            self.done_show = True
            self.html.LoadP age( self.HOME )
            >
            app = wx.PySimpleApp( )
            frm = MyHtmlFrame(Non e, "Simple HTML Browser")
            frm.Show()
            app.MainLoop()
            >
            Note: the URL you loading takes ages to show, which is why I
            use:http://www.google.co.ukabove.
            >
            Rob.
            --http://www.victim-prime.dsl.pipex .com/
            >
            To Rob Williscroft,
            >
            It works when I call LoadPage() in any event handler, though I don't
            know the reason. I'll try to learn it.
            Thank you.
            And the example in the book "wxPython In Action" is wrong?
            I know some of the examples from the book are no longer current, but I
            cannot recall if the HtmlWindow one was one of them or not. You can
            ask at the wxPython users group. Robin Dunn (one of the authors of the
            book) is one of the moderators there. http://wxpython.org/maillist.php

            I recommend using the examples in the wxPython Demo as they are
            usually the most current.

            Mike

            Comment

            • Jorgen Bodde

              #7
              Re: Why does not my wx.html.HtmlWin dow work?

              Hi,

              Coming from the wx community, I do know that the wx.HtmlWindow is NOT
              meant to load full blown web pages with. It has no concept of
              javascript, CSS, and other complex DOM properties.

              If you really want to display complex web pages in a window, look at
              wxMozilla or the wxIE binding.

              So the reason it freaks out might be related to the fact the page is
              too complex, or that the simplistic engine cannot cope with html tags
              out in the wild.

              Regards,
              - Jorgen

              On 4/8/07, Carsten Haese <carsten@uniqsy s.comwrote:
              On 7 Apr 2007 20:38:25 -0700, liqfemail@gmail .com wrote
              Below are my source code:
              [snip
              html.LoadPage("

              wxpython-part-1.html")
              [snip]
              >
              Have you tried loading a simpler page, something like http://www.google.com?
              >
              -Carsten
              >
              --

              >

              Comment

              Working...