2

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

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • Can you use [`WebView`](http://wxpython.org/Phoenix/docs/html/html2.WebView.html) instead? – lmjohns3 May 05 '14 at 23:37
  • unfortunately not unless there is a python package that just gives me that (I am using 2.8.10, and that isnt around until 2.9.3, and cant really update...) – Joran Beasley May 05 '14 at 23:50
  • @lmjohns3 thanks for the inspiration it looks like iewin will work fine, which is somewhat simillar (since im on windows ... I would rather make something more portable but meh) – Joran Beasley May 05 '14 at 23:57

2 Answers2

1

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.

Community
  • 1
  • 1
Appleman1234
  • 15,946
  • 45
  • 67
  • wxIE comes builtin ... I cannot just download, since the page I actually need to talk to is a form that needs to be submitted +1 for the suggestion all the same :) – Joran Beasley May 06 '14 at 04:14
1

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()
Joran Beasley
  • 110,522
  • 12
  • 160
  • 179