Skip to content

Commit acd574d

Browse files
committed
uic widget-plugins: do not crash if QGIS not installed
1 parent 0ff4985 commit acd574d

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

python/custom_widgets/qgis_customwidgets.py

+23-18
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,32 @@
2323
It is copied on installation in /pythonX/dist-packages/PyQt4/uic/widget-plugins/
2424
"""
2525

26-
#pluginType = CW_FILTER
27-
#def getFilter():
28-
# import qgis.gui
29-
#
30-
# QGIS_widgets = {}
31-
# for pyClass in dir(qgis.gui):
32-
# QGIS_widgets[pyClass] = 'qgis.gui'
33-
#
34-
# def _QGISfilter(widgetname, baseclassname, module):
35-
# print widgetname, baseclassname, module
36-
# if widgetname in QGIS_widgets:
37-
# return (MATCH, (widgetname, baseclassname, QGIS_widgets[widgetname]))
38-
# else:
39-
# return (NO_MATCH, None)
40-
#
41-
# return _QGISfilter
26+
# solution with CW_FILTER not fully working due to include of other files
27+
# (e.g. for flags defined in other source files)
4228

29+
# pluginType = CW_FILTER
30+
# def getFilter():
31+
# import qgis.gui
32+
#
33+
# QGIS_widgets = {}
34+
# for pyClass in dir(qgis.gui):
35+
# QGIS_widgets[pyClass] = 'qgis.gui'
36+
#
37+
# def _QGISfilter(widgetname, baseclassname, module):
38+
# print widgetname, baseclassname, module
39+
# if widgetname in QGIS_widgets:
40+
# return (MATCH, (widgetname, baseclassname, QGIS_widgets[widgetname]))
41+
# else:
42+
# return (NO_MATCH, None)
43+
#
44+
# return _QGISfilter
4345

4446

4547
pluginType = MODULE
4648
def moduleInformation():
47-
import qgis.gui
48-
return "qgis.gui", dir(qgis.gui)
49+
try:
50+
import qgis.gui
51+
return "qgis.gui", dir(qgis.gui)
52+
except ImportError:
53+
return "", []
4954

0 commit comments

Comments
 (0)