WebView2....Rhino 8 Python or C#?

Hello ,

I would like to load a javascript library for a plugin that need to be open with a webview, but the WebView1 has some limitations and need to access webview2… but direct access trough python is not yet available .
Rhino 8 offers the way to use WebView2 that is installed on my system, but how to access?.. directly seems not allowed, maybe through a C# plugin?..

Thanks for your help/

You can use webviews in IronPy 2.7, Py3, and C#
Whats your problem precisely?

1 Like

You could probably also keep using IronPython.

I try implement a javascript plugin, FrappeGantt, and by implementing it in a python 3 , I have problem to communicate between the webview and storing raw data of my planning in RhinoUsertext.
All these limitation should be solved if I load a WebView2 windows which is base on the chromium navigator, and have access to the Navigating function that is missing in WebView1 …
But it seems that webview2 is not nativetly accessible in python…

the test code:

#! python3
import Rhino
import Eto.Forms as forms
import Eto.Drawing as drawing

def test_webview2():
    try:
        # Tenter d'importer WebView2
        from Rhino.UI.Controls import WebView2
    except ImportError as e:
        # Afficher un message si l'importation échoue
        print("Impossible d'importer WebView2 :", e)
        return

    # Créer une fenêtre simple avec WebView2
    class WebView2Form(forms.Form):
        def __init__(self):
            super(WebView2Form, self).__init__()
            self.Title = "Test WebView2"
            self.ClientSize = drawing.Size(800, 600)
            self.Padding = drawing.Padding(5)

            self.webview = WebView2()
            self.webview.LoadHtml("<html><body><h1>Hello, WebView2!</h1></body></html>", None)

            self.Content = self.webview

    # Afficher la fenêtre
    form = WebView2Form()
    form.Owner = Rhino.UI.RhinoEtoApp.MainWindow
    form.Show()
    # Appeler la fonction pour tester WebView2
test_webview2()

@antoine If you want to use WebView2 then you must use C#

1 Like

… in Rhino 7

@nathanletwory … hum so WebView2 and Rhino8…it works or no? :slight_smile:

As far as I am aware it should work. @kiteboardshaper uses this I believe.

I’m using the stock WebView for both R7 and R8.

Rhino 7 uses WebView, Rhino 8 uses WebView2.

My plugins UI work a little nicer in R8 thanks to some more modern JS/Chrome features.

I’ve only briefly looked at how to get WebView2 working in R7, but honestly R8 is now working fine and is getting close to 1 year since first release. I consider R7 support to be legacy now.

Cheers

DK

1 Like

One other side note, WebUI for grasshopper, which hasn’t had much development recently, uses WebView2 in R7. I ran into issues with my own UI setup when WebUI was installed.

Cheers

DK

Thank you @kiteboardshaper but on R8, are you using python or C# when you want to use WebView2?..

I using stock standard Ironpython example code to launch Eto.WebView from this page:

Cheers

DK

Ok I understand so it automatically use WebView2 in R8 because I only found only WebView(1) references in the Rhino 8 libraries…
So my question for Mc Neel, is it a full WebView2 behind ? or a reduce version for Rhino only, because some javascript functions does not work properly inside a WebView2…

I’d used this to work out what browser was being used in each version, also different on MacOS. This will be where you are seeing JS/html support differences.

Cheers

DK