File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 25
25
26
26
from builtins import zip
27
27
import os
28
+ import sys
28
29
29
30
30
31
def setupenv ():
@@ -69,3 +70,20 @@ def setupenv():
69
70
70
71
71
72
from qgis .PyQt import QtCore
73
+
74
+ # monkey patching custom widgets in case we are running on a local install
75
+ # this should fix import errors such as "ModuleNotFoundError: No module named qgsfilewidget"
76
+ # ("from qgsfilewidget import QgsFileWidget")
77
+ # In a complete install, this is normally avoided and rather imports "qgis.gui"
78
+ # (thanks to uic/widget-plugins/qgis_customwidgets.py)
79
+ try :
80
+ import qgis .gui
81
+ widget_list = dir (qgis .gui )
82
+ # remove widgets that are not allowed as customwidgets (they need to be manually promoted)
83
+ skip_list = ['QgsScrollArea' ]
84
+ for widget in widget_list :
85
+ if widget .startswith ('Qgs' ) and widget not in skip_list :
86
+ sys .modules [widget .lower ()] = qgis .gui
87
+ except ImportError :
88
+ # gui might not be built
89
+ pass
You can’t perform that action at this time.
0 commit comments