Question

I am trying to load a https url into an HTMLWindow

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.HtmlWindow(self)
        if "gtk2" in wx.PlatformInfo:
            html.SetStandardFonts()

        wx.CallAfter(html.LoadPage, "https://www.google.com")#Fails to load page 
        #but the following works ...
        #wx.CallAfter(html.LoadPage, "http://www.google.com")#Works Fine!


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

Is there a way to load a ssl page in HTMLWindow (or some other in-a-wxWindow way to render ssl pages)?

I am using wx 2.8.10 , and upgrading is not really an option currently

Was it helpful?

Solution 2

I really wanted to grant my bounty to someone but really here is the solution that lmjohns led me too ... sort of ... the solution is to use wx IEWin

import wx
import wx.lib.iewin as iewin
class MyBrowser(wx.Dialog):
  def __init__(self, *args, **kwds):
    wx.Dialog.__init__(self, *args, **kwds)
    sizer = wx.BoxSizer(wx.VERTICAL)
    self.browser =  iewin.IEHtmlWindow(self)
    sizer.Add(self.browser, 1, wx.EXPAND, 10)
    self.SetSizer(sizer)
    self.SetSize((850, 730))
  def load(self,uri):
      self.browser.Navigate(uri)

if __name__ == '__main__':
  app = wx.App()
  dialog = MyBrowser(None, -1)
  dialog.browser.Navigate("https://www.google.com")
  dialog.Show()
  app.MainLoop()

OTHER TIPS

You can just download the file using an existing method like urllib2.urlopen, and save the file to the filesystem and then pass that filename to the LoadPage method of HtmlWindow.

Examples of existing methods are covered in the following StackOverflow questions, HTTPS connection Python and How do I download a file over HTTP using Python?

Other options that are more complicated involve using wxIE and wxMozilla, once your have downloaded or compiled the Python bindings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top