WxWebkit fails loading local background image

The following code snippet works nicely with a remote image, but fails
to load a local one:

http://pastebin.com/f2e39d20

Tried loading the html part in Safari and worked fine for both cases.

Python 2.6.2, Mac OS X 10.5.8, WxPython 2.8.10.1

The browser needs to know the location of the html file to know how to resolve relative references to other document components. When you load the document from an in memory string there is no context to prepend to relative links so it's unable to find them. My guess is that if you use a file:// URL with the full path of the file then it will work. Adding a <base> tag to the header with the base location for the relative links will probably also work.

···

On 11/12/09 7:49 AM, Gabriel Andrade wrote:

The following code snippet works nicely with a remote image, but fails
to load a local one:

# -*- coding: utf-8 -*-import wximport wx.webkitsource = '''<html> - Pastebin.com

Tried loading the html part in Safari and worked fine for both cases.

--
Robin Dunn
Software Craftsman

Hi Robin & Gabriel,

The following code snippet works nicely with a remote image, but
fails
to load a local one:

# -*- coding: utf-8 -*-import wximport wx.webkitsource = '''<html> - Pastebin.com

Tried loading the html part in Safari and worked fine for both cases.

The browser needs to know the location of the html file to know how to
resolve relative references to other document components. When you
load
the document from an in memory string there is no context to prepend
to
relative links so it's unable to find them. My guess is that if you
use
a file:// URL with the full path of the file then it will work.
Adding
a <base> tag to the header with the base location for the relative
links
will probably also work.

Another way to do it is to pass the base URL as the second argument of
SetPageSource, e.g.

SetPageSource(source, "file:///path/to/image/root")

Regards,

Kevin

···

On Nov 12, 2009, at 9:57 AM, Robin Dunn wrote:

On 11/12/09 7:49 AM, Gabriel Andrade wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org

>

Thanks Kevin!

And Mike, you're right, it missed an absolute path.

But now, running this code on Windows gives me the following error:

File "X:\untitled.py", line 38, in __init__
    self.webkit = wx.webkit.WebKitCtrl(self, -1)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\webkit.py",
line 72, in __init__
    _webkit.WebKitCtrl_swiginit(self,_webkit.new_WebKitCtrl(*args, **kwargs))
NotImplementedError

Windows XP SP3, Python 2.6.2, WxPython 2.8.10.1

···

On Thu, Nov 12, 2009 at 4:11 PM, Kevin Ollivier <kevin-lists@theolliviers.com> wrote:

Hi Robin & Gabriel,
Another way to do it is to pass the base URL as the second argument of
SetPageSource, e.g.

SetPageSource(source, "file:///path/to/image/root")

Hmmm...changing wx.webkit.WebKitCtrl() to wx.webview.WebView() make it work.

Can someone clarify me the conceptual difference between those..?

···

On Thu, Nov 12, 2009 at 4:22 PM, Gabriel Andrade <gabiruh@gmail.com> wrote:

File "X:\untitled.py", line 38, in __init__
self.webkit = wx.webkit.WebKitCtrl(self, -1)
File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\webkit.py",
line 72, in __init__
_webkit.WebKitCtrl_swiginit(self,_webkit.new_WebKitCtrl(*args, **kwargs))
NotImplementedError

The old wx.webkit module is a Mac-only wrapper around the native WebKit library distributed by Apple. (You could think of it as the native html renderer for OS X like IE (sorta) is for Windows.)

If you want to use the new cross platform version of wxWebKit then you'll need to get the preview build from here: NameBright - Coming Soon and import it as wx.webview.

···

On 11/12/09 11:22 AM, Gabriel Andrade wrote:

On Thu, Nov 12, 2009 at 4:11 PM, Kevin Ollivier > <kevin-lists@theolliviers.com> wrote:

Hi Robin& Gabriel,
Another way to do it is to pass the base URL as the second argument of
SetPageSource, e.g.

SetPageSource(source, "file:///path/to/image/root")

Thanks Kevin!

And Mike, you're right, it missed an absolute path.

But now, running this code on Windows gives me the following error:

File "X:\untitled.py", line 38, in __init__
     self.webkit = wx.webkit.WebKitCtrl(self, -1)
   File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\webkit.py",
line 72, in __init__
     _webkit.WebKitCtrl_swiginit(self,_webkit.new_WebKitCtrl(*args, **kwargs))
NotImplementedError

Windows XP SP3, Python 2.6.2, WxPython 2.8.10.1

--
Robin Dunn
Software Craftsman