Problem with using QGIS custom widgets in plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with using QGIS custom widgets in plugin

Alexander Bruy
Hi all,

I use QGIS custom widgets in my plugin, namely QgsMaplayerComboBox.
When I run QGIS under Linux all works fine, but under Windows I got Python
error on startup related to missed enum entries:

   File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\__init__.py",
line 210, in loadUiType
    winfo = compiler.UICompiler().compileUi(uifile, code_string,
from_imports, resource_suffix)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\Compiler\compiler.py",
line 139, in compileUi
    w = self.parse(input_stream, resource_suffix)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 992, in parse
    actor(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 818, in createUserInterface
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 507, in createLayout
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 550, in handleItem
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 258, in createWidget
    self.stack.push(self.setupObject(widget_class, parent, elem))
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 220, in setupObject
    self.wprops.setProperties(obj, branch)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 418, in setProperties
    prop_value = self.convert(prop, widget)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 383, in convert
    return func(prop[0], **args)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 116, in _set
    expr = [self._pyEnumMember(v) for v in prop.text.split('|')]
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 111, in _pyEnumMember
    raise AttributeError("unknown enum %s" % cpp_name)
AttributeError: unknown enum QgsMapLayerProxyModel::RasterLayer

I use QGIS LTR installed via OSGeo4W installer. Same problem also exists
with dev and release versions. Any ideas what is wrong and how to fix this?

Thanks
--
Alexander Bruy
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Problem with using QGIS custom widgets in plugin

enricofer
I got a similar issue using QgsFieldExpressionWidget.
After compiling ui with pyuic4 I found that the import statement at the end of the compiled .py was wrong. So I manually changed it to:
from qgis.gui import QgsFieldExpressionWidget

Regards

Enrico Ferreguti

2015-11-16 10:30 GMT+01:00 Alexander Bruy [via OSGeo.org] <[hidden email]>:
Hi all,

I use QGIS custom widgets in my plugin, namely QgsMaplayerComboBox.
When I run QGIS under Linux all works fine, but under Windows I got Python
error on startup related to missed enum entries:

   File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\__init__.py",
line 210, in loadUiType
    winfo = compiler.UICompiler().compileUi(uifile, code_string,
from_imports, resource_suffix)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\Compiler\compiler.py",
line 139, in compileUi
    w = self.parse(input_stream, resource_suffix)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 992, in parse
    actor(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 818, in createUserInterface
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 507, in createLayout
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 550, in handleItem
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 258, in createWidget
    self.stack.push(self.setupObject(widget_class, parent, elem))
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 220, in setupObject
    self.wprops.setProperties(obj, branch)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 418, in setProperties
    prop_value = self.convert(prop, widget)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 383, in convert
    return func(prop[0], **args)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 116, in _set
    expr = [self._pyEnumMember(v) for v in prop.text.split('|')]
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 111, in _pyEnumMember
    raise AttributeError("unknown enum %s" % cpp_name)
AttributeError: unknown enum QgsMapLayerProxyModel::RasterLayer

I use QGIS LTR installed via OSGeo4W installer. Same problem also exists
with dev and release versions. Any ideas what is wrong and how to fix this?

Thanks
--
Alexander Bruy
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/Problem-with-using-QGIS-custom-widgets-in-plugin-tp5236556.html
To unsubscribe from Quantum GIS - Developer, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Problem with using QGIS custom widgets in plugin

Lauri Kajan
This was discussed earlier on the list http://osgeo-org.1560.x6.nabble.com/Compiling-ui-files-with-custom-widgets-creates-wrong-imports-td5218684.html
Here's the bug report http://hub.qgis.org/issues/13428

This happens because PyQt is not aware of qgis_customwidgets.py located in qgis\python\PyQt4\uic\widget-plugins folder.


-Lauri

On Mon, Nov 16, 2015 at 12:05 PM, enricofer <[hidden email]> wrote:
I got a similar issue using QgsFieldExpressionWidget.
After compiling ui with pyuic4 I found that the import statement at the end of the compiled .py was wrong. So I manually changed it to:
from qgis.gui import QgsFieldExpressionWidget

Regards

Enrico Ferreguti

2015-11-16 10:30 GMT+01:00 Alexander Bruy [via OSGeo.org] <[hidden email]>:
Hi all,

I use QGIS custom widgets in my plugin, namely QgsMaplayerComboBox.
When I run QGIS under Linux all works fine, but under Windows I got Python
error on startup related to missed enum entries:

   File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\__init__.py",
line 210, in loadUiType
    winfo = compiler.UICompiler().compileUi(uifile, code_string,
from_imports, resource_suffix)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\Compiler\compiler.py",
line 139, in compileUi
    w = self.parse(input_stream, resource_suffix)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 992, in parse
    actor(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 818, in createUserInterface
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 507, in createLayout
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 550, in handleItem
    self.traverseWidgetTree(elem)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 796, in traverseWidgetTree
    handler(self, child)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 258, in createWidget
    self.stack.push(self.setupObject(widget_class, parent, elem))
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\uiparser.py",
line 220, in setupObject
    self.wprops.setProperties(obj, branch)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 418, in setProperties
    prop_value = self.convert(prop, widget)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 383, in convert
    return func(prop[0], **args)
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 116, in _set
    expr = [self._pyEnumMember(v) for v in prop.text.split('|')]
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\PyQt4\uic\properties.py",
line 111, in _pyEnumMember
    raise AttributeError("unknown enum %s" % cpp_name)
AttributeError: unknown enum QgsMapLayerProxyModel::RasterLayer

I use QGIS LTR installed via OSGeo4W installer. Same problem also exists
with dev and release versions. Any ideas what is wrong and how to fix this?

Thanks
--
Alexander Bruy
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1560.x6.nabble.com/Problem-with-using-QGIS-custom-widgets-in-plugin-tp5236556.html
To unsubscribe from Quantum GIS - Developer, click here.
NAML



View this message in context: Re: Problem with using QGIS custom widgets in plugin
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.

_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Problem with using QGIS custom widgets in plugin

lennepkade
This post has NOT been accepted by the mailing list yet.
Hello,
I have exactly the same problem... Is there a simple way to correct it ?
I didn't manage to solve it, QgsMapLayerProxyModel still block the plugin :(
Reply | Threaded
Open this post in threaded view
|

Re: Problem with using QGIS custom widgets in plugin

lennepkade
In reply to this post by Lauri Kajan
I manage to find a issue for this problem. You have to compile your UI (even if it is your main UI) and change your call.
Here are details : http://www.lennepka.de/how-to-get-rid-of-unknown-enum-qgsmaplayerproxymodelpluginlayer-in-qgis/
Hope that could help.