【问题标题】:loading https page into wx.html.HTMLWindow将 https 页面加载到 wx.html.HTMLWindow
【发布时间】:2014-04-30 15:37:06
【问题描述】:

我正在尝试将 https url 加载到 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()

有没有办法在 HTMLWindow 中加载 ssl 页面(或其他一些 in-a-wxWindow 方式来呈现 ssl 页面)?

我正在使用 wx 2.8.10 ,目前升级不是一个真正的选择

【问题讨论】:

  • 你能用WebView代替吗?
  • 不幸的是没有,除非有一个 python 包可以给我(我使用的是 2.8.10,直到 2.9.3 才出现,并且不能真正更新......)
  • @lmjohns3 感谢您的灵感,看起来 iewin 可以正常工作,这有点相似(因为我在 Windows 上......我宁愿做一些更便携的东西,但是嗯)

标签: python ssl https wxwidgets wxhtmlwindow


【解决方案1】:

您可以使用现有方法(如urllib2.urlopen)下载文件,并将文件保存到文件系统,然后将该文件名传递给 HtmlWindow 的 LoadPage 方法。

以下 StackOverflow 问题HTTPS connection Python 和 How do I download a file over HTTP using Python? 中介绍了现有方法的示例

其他更复杂的选项涉及使用 wxIE 和 wxMozilla,一旦您下载或编译了 Python 绑定。

【讨论】:

  • wxIE 是内置的......我不能只下载,因为我真正需要与之交谈的页面是一个需要提交 +1 以获取建议的表单:)
【解决方案2】:

我真的很想将我的赏金授予某人,但实际上这也是 lmjohns 引导我的解决方案......有点......解决方案是使用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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-27
    • 2012-11-01
    • 2015-05-03
    • 2013-11-02
    • 1970-01-01
    • 2014-04-20
    • 2018-07-21
    • 1970-01-01
    相关资源
    最近更新 更多