r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.73k stars 554 forks source link

webview.load_html not showing image. #101

Closed JeanPierreFig closed 7 years ago

JeanPierreFig commented 7 years ago

On a Raspberry Pi I am trying to load an html page that just makes the background black and centers the image on screen, but I'm getting this error

Message: console message: @32 Not allowed to load local resource: FilePath

shivaprsd commented 7 years ago

This probably is not a pywebview issue. You seems to be accessing a local file at an absolute path, which is restricted by sandboxing for security reasons.

See http://stackoverflow.com/questions/39007243/cannot-open-local-file-chrome-not-allowed-to-load-local-resource.

Can you show us the HTML your are trying to load?

JeanPierreFig commented 7 years ago

Yeah That's what I thought, I was testing it first on a mac and it worked. I think the problem is that the raspberry pi Uses Chromium as it's base.


html = """

        <!DOCTYPE html>
        <html>

        <head>

        </head>
        <style media="screen">

        body{
        background-color: black;

        }

        .center {
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        left: 0;
        margin: auto;
        overflow: auto;
        position: fixed;
        right: 0;
        top: 0;

        }
        </style>

        <body>

        <img src="/data/" alt="HTML5 Icon" class="center">

        </body>

        </html>

        """.replace('/data/', data)

This is the string that I am passing. data is file:///home/pi/images/imageName interestingly if I pass the image file alone with out html then it works but I need the styling

r0x0r commented 7 years ago

First things first, GTK or QT?

r0x0r commented 7 years ago

Try the relative path instead

shivaprsd commented 7 years ago

Also, have you tried saving the code in an .html file and running it in a web browser in the same machine?

r0x0r commented 7 years ago

@JeanPierreFig Is this still relevant?

edif commented 3 years ago

"Not allowed to load local resource"