redirect custom widget includes to qgis.gui

This commit is contained in:
Denis Rouzaud 2014-05-02 11:42:37 +02:00
parent 196d7d8e77
commit ee522ec500
4 changed files with 44 additions and 0 deletions

View File

@ -179,6 +179,7 @@ ENDIF(WITH_QSCIAPI)
SET(PY_FILES
__init__.py
utils.py
customwidgets.py
)
ADD_CUSTOM_TARGET(pyutils ALL)

View File

@ -24,6 +24,8 @@ __copyright__ = '(C) 2007, Martin Dobias'
__revision__ = '$Format:%H$'
import sip
from customwidgets import referenceCustomWidgets
try:
apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"]
for api in apis:
@ -34,6 +36,8 @@ except ValueError:
from qgis.core import QgsFeature, QgsGeometry
referenceCustomWidgets()
try:
# Add a __nonzero__ method onto QPyNullVariant so we can check for null values easier.
# >>> value = QPyNullVariant("int")

33
python/customwidgets.py Normal file
View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""
***************************************************************************
customwidgets.py
---------------------
Date : May 2014
Copyright : (C) 2014 by Denis Rouzaud
Email : denis.rouzaud@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
import sys
import qgis
from qgis import gui
"""
This allow to redirect the custom widget include header file to qgis.gui
"""
def referenceCustomWidgets():
sys.modules["qgscollapsiblegroupboxplugin"] = qgis.gui
sys.modules["qgsfieldcomboboxplugin"] = qgis.gui
sys.modules["qgsfieldexpressionwidgetplugin"] = qgis.gui
sys.modules["qgsmaplayercomboboxplugin"] = qgis.gui
sys.modules["qgsscalevisibilitywidgetplugin"] = qgis.gui

View File

@ -27,6 +27,12 @@
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
: QObject( parent )
{
// !!!!!!!!!!!!!!!!!!!!!
// do not forget to add the corresponding line in python/customwidgets.py
// to make the custom widget available from python
// !!!!!!!!!!!!!!!!!!!!!
mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
mWidgets.append( new QgsFieldComboBoxPlugin );
mWidgets.append( new QgsFieldExpressionWidgetPlugin );