Skip to content

Commit ee522ec

Browse files
committed
redirect custom widget includes to qgis.gui
1 parent 196d7d8 commit ee522ec

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ ENDIF(WITH_QSCIAPI)
179179
SET(PY_FILES
180180
__init__.py
181181
utils.py
182+
customwidgets.py
182183
)
183184

184185
ADD_CUSTOM_TARGET(pyutils ALL)

python/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
__revision__ = '$Format:%H$'
2525

2626
import sip
27+
from customwidgets import referenceCustomWidgets
28+
2729
try:
2830
apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"]
2931
for api in apis:
@@ -34,6 +36,8 @@
3436

3537
from qgis.core import QgsFeature, QgsGeometry
3638

39+
referenceCustomWidgets()
40+
3741
try:
3842
# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
3943
# >>> value = QPyNullVariant("int")

python/customwidgets.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
customwidgets.py
6+
---------------------
7+
Date : May 2014
8+
Copyright : (C) 2014 by Denis Rouzaud
9+
Email : denis.rouzaud@gmail.com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
import sys
21+
import qgis
22+
from qgis import gui
23+
24+
"""
25+
This allow to redirect the custom widget include header file to qgis.gui
26+
"""
27+
28+
def referenceCustomWidgets():
29+
sys.modules["qgscollapsiblegroupboxplugin"] = qgis.gui
30+
sys.modules["qgsfieldcomboboxplugin"] = qgis.gui
31+
sys.modules["qgsfieldexpressionwidgetplugin"] = qgis.gui
32+
sys.modules["qgsmaplayercomboboxplugin"] = qgis.gui
33+
sys.modules["qgsscalevisibilitywidgetplugin"] = qgis.gui

src/customwidgets/qgiscustomwidgets.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
2828
: QObject( parent )
2929
{
30+
31+
// !!!!!!!!!!!!!!!!!!!!!
32+
// do not forget to add the corresponding line in python/customwidgets.py
33+
// to make the custom widget available from python
34+
// !!!!!!!!!!!!!!!!!!!!!
35+
3036
mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
3137
mWidgets.append( new QgsFieldComboBoxPlugin );
3238
mWidgets.append( new QgsFieldExpressionWidgetPlugin );

0 commit comments

Comments
 (0)