question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When written as a sample, webview.load_html() is sometimes called before the webview is ready.

See original GitHub issue

Specification

  • Platform: Windows 10 1809 Build 17763.379
  • Version: 2.4(Rendering Engine: Trident)

Description

A sample of the load_html() described in sample page is written as follows.

def load_html():
    webview.load_html('<h1>This is dynamically loaded HTML</h1>')

if __name__ == '__main__':
    t = threading.Thread(target=load_html)
    t.start()

    webview.create_window('Load HTML Example')

However, in this case, in a low-spec PC environment, such as the Atom CPU, webview#load_html() is invoked before WebView is ready and may cause an error.

As follows, it seems that it is desirable to perform the ready waiting for WebView.

def load_html():
    webview.webview_ready()
    webview.load_html('<h1>This is dynamically loaded HTML</h1>')

if __name__ == '__main__':
    t = threading.Thread(target=load_html)
    t.start()

    webview.create_window('Load HTML Example')

What to expect.

The program works in many environments by writing it as shown in the sample.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
r0x0rcommented, Apr 5, 2019

I have changed the timeout to 15 seconds and made it to throw a separate exception if the window is not opened by then. Closing this.

0reactions
TakamiChiecommented, Mar 29, 2019

When I tried to edit the above line, the error certainly no longer occurred.

        try:
            _webview_ready.wait(10)
            return function(*args, **kwargs)
        except NameError:
            raise Exception('Create a web view window first, before invoking this function')
        except KeyError as e:
  • pywebview/WebView/init.py Pre-edited: tried to start 20 times and four times the error.
  • After editing: 20 attempts to start and without error.

Also, running the application in GPD Pocket, the error is no longer occur, it is considered to have been sufficiently effective.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to load html string in a webview? - android - Stack Overflow
To load your data in WebView. Call loadData() method of WebView wv.loadData(yourData, "text/html", "UTF-8");. You can check this example.
Read more >
Chapter 4. WebView, WebKit, and WebSettings - O'Reilly
A WebView is often used to load HTML content within a native application. The WebView enables you to embed a web browser, which...
Read more >
WebView - Android Developers
Overview Guides Samples Design & Quality · Android Developers · Platform · Android Studio · Google Play · Jetpack · Kotlin · Docs....
Read more >
WebView Tutorial With Example In Android Studio
This method is used to load the static HTML string in a web view. loadData() function takes html string data, mime-type and encoding...
Read more >
Adding WebView to your Flutter app - Google Codelabs
The plugin can render Flutter widgets over the web view. So for example it's possible to render a drop down menu over the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found