Skip to content

Commit 73553d8

Browse files
authored
fix: try more options when failed to use netfx when import clr (#1791)
1 parent 09ff8c3 commit 73553d8

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

webview/platforms/edgechromium.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
import winreg
77
from threading import Semaphore
88

9-
import clr
9+
try:
10+
import clr
11+
except Exception:
12+
os.environ['PYTHONNET_RUNTIME'] = 'coreclr'
13+
import clr
1014

1115
from webview import Window, _state
1216
from webview import settings as webview_settings

webview/platforms/mshtml.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
from ctypes import windll
66
from threading import Semaphore
77

8-
import clr
8+
try:
9+
import clr
10+
except Exception:
11+
import os
12+
13+
os.environ['PYTHONNET_RUNTIME'] = 'coreclr'
14+
import clr
915

1016
from webview import _state
1117
from webview.util import (

webview/platforms/winforms.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
from platform import machine
1111
from threading import Event, Semaphore
1212

13-
import clr
13+
try:
14+
import clr
15+
except Exception:
16+
os.environ['PYTHONNET_RUNTIME'] = 'coreclr'
17+
import clr
1418

1519
from webview import FileDialog, _state, settings, windows
1620
from webview.guilib import forced_gui_

0 commit comments

Comments
 (0)