WebView2 in notebooks

60 views
Skip to first unread message

Andreas Lenhardt

unread,
Dec 8, 2020, 5:32:30 AM12/8/20
to wx-users

Hello,

I want to have multiple pages in my notebook, each with a webview as content.
The backend I want to use is the new Edge backend.
Unfortunately, the webview only works in the first notebok page, not in the others.
Can someone give me a hint what to do, or is this a bug and has to be reported?
I am using wxpython on win10.

Kind regards
Andreas

Eric Jensen

unread,
Dec 8, 2020, 11:59:58 AM12/8/20
to 'Andreas Lenhardt' via wx-users
Hello 'Andreas,

Tuesday, December 8, 2020, 11:32:30 AM, you wrote:


ALvwu> Hello,
ALvwu> I want to have multiple pages in my notebook, each with a
ALvwu> webview as content.The backend I want to use is the new Edge
ALvwu> backend.Unfortunately, the webview only works in the first
ALvwu> notebok page, not in the others.Can someone give me a hint what
ALvwu> to do, or is this a bug and has to be reported?I am using wxpython on win10.
ALvwu> Kind regardsAndreas


I think this was caused by this bug: https://trac.wxwidgets.org/ticket/18851

But AFAIK it has been fixed recently, although i can't find the commit
at the moment.

But i don't know how longs it takes to make its way into wxPython.

Eric


--

PB

unread,
Dec 8, 2020, 2:11:47 PM12/8/20
to wx-users
Dne úterý 8. prosince 2020 v 17:59:58 UTC+1 uživatel Eric Jensen napsal:
I think this was caused by this bug: https://trac.wxwidgets.org/ticket/18851

But AFAIK it has been fixed recently, although i can't find the commit
at the moment.

as the second commit in the PR.

PB

unread,
Dec 8, 2020, 3:13:07 PM12/8/20
to wx-users
I can confirm what Eric wrote, i.e., that the modified sample he added in ticket 18851 still does not work.

However, using simplest possible example, it does work with wxNotebook (it may take a bit before the webview appears if it is the first time it is loaded):
#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/webview.h>

class MyFrame : public wxFrame
{
public:
    MyFrame () : wxFrame(nullptr, wxID_ANY, "Test wxWebViewBackendEdge", wxDefaultPosition, wxSize(1024,768))
    {
        if ( !wxWebView::IsBackendAvailable(wxWebViewBackendEdge) )
        {
            wxLogError("wxWebViewBackendEdge not available");
            return;
        }

        wxNotebook* notebook = new wxNotebook(this, wxID_ANY);

        AddPage(notebook, "What is my browser", "https://www.whatismybrowser.com/");
        AddPage(notebook, "wxWidgets website","https://wxwidgets.org");
        AddPage(notebook, "wxWidgets GitHub", "https://github.com/wxWidgets");
        AddPage(notebook, "wxWidgets Docs", "https://docs.wxwidgets.org/");
    }
private:
    void AddPage(wxNotebook* notebook, const wxString& name, const wxString& URL)
    {
        notebook->AddPage(wxWebView::New(notebook, wxID_ANY, URL,
            wxDefaultPosition, wxDefaultSize, wxWebViewBackendEdge), name);
    }
};

class MyApp : public wxApp
{
public:
    bool OnInit() override
    {
        (new MyFrame())->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);



I am on Windows 10 and I used wxWidgets 64-bit DLL build, webview2 nuget package v1.0.664.37 and today's Evergreen Bootstrapper (Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.57).

Robin Dunn

unread,
Dec 8, 2020, 3:30:22 PM12/8/20
to wx-users
That commit was included in the 4.1.1 release of wxPython, so it appears that the issue still exists.

PB

unread,
Dec 8, 2020, 4:24:36 PM12/8/20
to wx-users
The original issue may still exist but as written in my previous e-mail, the Edge-based wxWebView seems to work in a wxNotebook in a simple example.

Do we know if the OP uses quite recent wxPython 4.1.1?

Dne úterý 8. prosince 2020 v 21:30:22 UTC+1 uživatel Robin Dunn napsal:

Andreas Lenhardt

unread,
Dec 8, 2020, 4:29:15 PM12/8/20
to wx-users
Yes, OP uses the newest wxpython version :-)
Reply all
Reply to author
Forward
0 new messages