[Qgis-developer] Problems with using QGIS Custom Widgets
Denis Rouzaud
denis.rouzaud at gmail.com
Wed Aug 17 07:20:44 PDT 2016
Hi,
QgsColorButtonV2 is a QGIS custom widget.
When compiling the UI file having a custom widget, uic needs to find the
qgis gui library which has its definition.
That means you have to specify the QGIS python directory in your python
path. This works fine when using pyuic4 in command line.
I am not sure about uic.loadType. Why not using pyuic4 directly?
Maybe this is relevant:
https://lists.osgeo.org/pipermail/qgis-developer/2015-September/039196.html
Cheers,
Denis
On 08/17/2016 04:09 PM, Casper Børgesen (CABO) wrote:
>
> Hi Calvin
>
>
>
> I’m facing the same problem and before I go home I just wanted to ask
> if you found a solution to this problem?
>
>
>
>
>
> Regards, Casper
>
>
>
> *From:*Qgis-developer [mailto:qgis-developer-bounces at lists.osgeo.org]
> *On Behalf Of *C Hamilton
> *Sent:* 30. juni 2016 20:45
> *To:* qgis-developer
> *Subject:* [Qgis-developer] Problems with using QGIS Custom Widgets
>
>
>
> I am using Qt Designer to add a QgsColorButtonV2 to the ui of a QGIS
> plugin. I am using uic.loadUiType to load my .ui file. Specifically
> here is the line of code:
>
> FORM_CLASS, _ = uic.loadUiType(os.path.join(
> os.path.dirname(__file__), 'heatmapdialog.ui'))
>
> When I load the plugin in QGIS I get the error:
>
> ---------------------------
> ImportError: No module named qgscolorbuttonv2
>
> Traceback (most recent call last):
> File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 306, in
> startPlugin
> plugins[packageName] = package.classFactory(iface)
> File "C:/Users/Calvin/.qgis2/python/plugins\d3datavis\__init__.py",
> line 2, in classFactory
> from .d3datavis import D3DataVis
> File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 572, in _import
> mod = _builtin_import(name, globals, locals, fromlist, level)
> File "C:/Users/Calvin/.qgis2/python/plugins\d3datavis\d3datavis.py",
> line 10, in
> from heatmapDialog import HeatmapDialog
> File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 572, in _import
> mod = _builtin_import(name, globals, locals, fromlist, level)
> File
> "C:/Users/Calvin/.qgis2/python/plugins\d3datavis\heatmapDialog.py",
> line 17, in
> os.path.dirname(__file__), 'heatmapdialog.ui'))
> File
> "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\__init__.py",
> line 213, in loadUiType
> exec(code_string.getvalue(), ui_globals)
> File "", line 169, in
> File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 572, in _import
> mod = _builtin_import(name, globals, locals, fromlist, level)
> ImportError: No module named qgscolorbuttonv2
> ---------------------------
>
> In my code I have the import line:
>
> from qgis.gui import *
>
> From the QGIS console if I do that import, QgsColorButtonV2 is available.
>
> It appears that uic.loadUiType is the problem. How do I solve this?
>
> Thanks,
>
> Calvin
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160817/71fd6c0f/attachment-0001.html>
More information about the Qgis-developer
mailing list