The code runs without an error, but the browser window doesn’t open. Is this operation not supported on macOS, or am I doing something wrong? Thank you!
Hi, Dale! Sorry for the late answer - I didn’t get a notification of your reply. The script you provided generates no output; I modified it to make sure it actually ran. Where from here? Thanks!
webbrowser.py is part of the standard library that comes with IronPython, the interpreter used by Rhino. If it doesn’t work on macOS, I doubt there is anything we can do about it.
Okay, it sounds like this is an IronPython on Mac limitation, then… thanks! I would like to have my plugin be able to open a URL under various circumstances for help, authentication, and other support functions.
For a little extra context, the IronPython docs suggest that webbrowser is supported on macOS, as it mentions a “macosx” option that, it seems, should open the default browser.
However, this script, which attempts to create a browser controller object:
import webbrowser as wb
b = wb.get("macosx")
print(b)
generates the following error:
Message: could not locate runnable browser
Traceback:
line 52, in get, "/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/webbrowser.py"
line 2, in <module>, "/var/folders/7t/36p4w6_d4m1_8p5zkdrkdp9r0000gn/T/TempScript.py"
Dunno if that dump gives you any insight as to whether this could be specific to Rhino or not, but I thought I’d pass it along… thanks again!
That did the trick! Opened Safari like a champ. This is some slightly dark magic, it appears… is it okay to use System.Diagnostics for stuff like this? I suppose you gotta do what you gotta do… Thank you!