MS Edge backend fails in Notebook (other than first page)

Thanks everyone for chiming in here. I wish I had more bandwidth to keep troubleshooting with you. I’ll try to give @Robin’s non wx.Panel a shot this weekend.

Just for context to the conversation, I’m hi-jacking the wx.html2 for fancier UI… using Bokeh to generate JS plots. So my application has several “web browsers” displaying different local html files.

Thanks for these workarounds, they work fine imho.

May I ask if it is possible to respond to several in-browser events?
F.e. opening a link in the default browser when a link is clicked inside of the webview.
Or if desktop notifications are supported?

There are some specific events: https://wxpython.org/Phoenix/docs/html/wx.html2.WebView.html#events-events-emitted-by-this-class

E.g. EVT_WEBVIEW_NAVIGATING

See also the HTML2_WebView.py demo.

Alternatively, you may serve the html pages locally or as a proxy via localhost.
But then you are at a point where you should ask yourself, whether your architecture makes sense…

Quick update: @Robin’s latest example works for me too. It’ll take some time to apply this approach to my application, but looks promising so far.

Unfortunately, @Robin’s example doesn’t work for my situation. My tabs contain other wx objects. Perhaps there’s another container object I could try other than wx.Panel? The screenshot here is using the IE backend.

Thanks, I will try these.
I don’t know if you know the “Franz” messenger.
This application basically serves multiple messenger pages, f.e. whatsapp web, Gmail in own tabs.
But since it is based on electron it’s very Ressource heavy.
I wanted to make something similar for myself.
And since many links are sent I want them to be opened in my default browser.
Maybe in a future version notifications might work as well :slight_smile:

@andileni Just my two cents, but I think you’d be better off leaving the tabs to the webview. Have you seen CEF Python? https://github.com/cztomczak/cefpython

@cutright Thanks for that hint.
The webview has the same function as cefpython, or did I understand something wrong?
Or do you mean cefpython offers more options?

@cutright:
Try the delayed loading whether it’s an option for you. Of course it introduces a short delay.

https://discuss.wxpython.org/t/ms-edge-backend-fails-in-notebook-other-than-first-page/35036/20?u=dietmarschwertberger

@DietmarSchwertberger Yeah… I tried a delay too, I went as high as 0.1s delays. But maybe I didn’t place it in the right spot, I’ll try again putting it immediately after the WebView creation.

@andileni I don’t have first hand experience coding with cef python, but someone demoed an app to me with it. He used wxPython just for a basic App and Frame. Then he embedded his VueJS web app in that. Super slick. The advantage here is you can have chromium embedded in the exe, so you wouldn’t have to make your users install MS Edge. I wish I could elaborate more than that.

Oh I see. Thanks for the elaboration.
I don’t know if it suits my needs, since most messengers are not embeddable via iframe, but I will definitely give it a try.

@cutright:
Sorry, should have written “on-demand”, not “delayed”. Please have a look at the previous, linked post.

Your on-demand example code works for me. It will take me a while to implement with my code though. Perhaps I should have picked a smaller project to learn wxPython, it’s a bit of a mess :slight_smile:

Would matplotlib have worked for your plots?
It’s a bit easier to integrate with wx.
I have included examples with wxGlade. The one showing the most integration features is at https://github.com/wxGlade/wxGlade/tree/master/examples/matplotlib3

(The weak point for business applications is the export to office applications, though, as MS still does not really support SVG and also matplotlib does not use the standard fonts of the OS.)

In retrospect, matplotlib probably would have been better. My original project was 100% Bokeh (because I didn’t know what a proper framework should be then). But eventually the layout out-grew what bokeh could handle and I ported a lot of the code over to wxPython.

I’ve actually moved on to VueJS and amCharts for future projects. And then we’ll embed that into wxPython for desktop verisons.

Quick update. I managed to get @DietmarSchwertberger’s event method to work with my code. Unfortunately for me, I have a lot more edits to make for the other browsers to work. But I’m optimistic now.

image

New working theory. I think putting a webview with Edge backend into a tab requires it to be generated while the tab is selected? There is another requirement, but I haven’t teased it out yet.

I rearranged my code so webviews are created after the corresponding wx.Notebook.AddPage. If I call wx.Notebook.SetSelection before a webview is created, then it is displayed. Unless I have multiple webviews, then it only works on one webview, the last webview created while it’s parent is selected.

I tried injecting 10seconds in between, but it’s not time that is needed to complete the webview creation. I also called LoadURL("http://www.google.com") before moving on to the next tab, but that did not work either.