Hi, I (or we) also use the same method as Arnaud. The only drawback is you can’t get the autocomplete from the python file (from the ui file). But the benefit is greater: no need to ship generated python code, no need to compile every time we change the .ui file. The development is faster now.
I don’t think we need to see the generated python code from the .ui file. You can see here for the utilities method : https://github.com/inasafe/inasafe/blob/develop/safe/utilities/resources.py#L107 <https://github.com/inasafe/inasafe/blob/develop/safe/utilities/resources.py#L107> Best Regards > On 12May, 2017, at 12:34, Michal Zimmermann <zimm...@gmail.com> wrote: > > Hi, > that looks like an interesting workaround! What are the pitfalls? Don't you > need to see the real python code when developing? > > On Thu, May 11, 2017 at 1:55 PM, Arnaud Morvan <arnaud.mor...@camptocamp.com > <mailto:arnaud.mor...@camptocamp.com>> wrote: > Hello Michal, > > I've also had this error some times ago, I do not remember if I succeed with > pyuic4, nor the solution. > > But IMHO it is simpler to load "ui" files at runtime. > Here is an example from "processing" plugin : > > import os > from qgis.PyQt import uic > > pluginPath = os.path.split(os.path.dirname(__file__))[0] > WIDGET, BASE = uic.loadUiType( > os.path.join(pluginPath, 'ui', 'DlgConfig.ui')) > > class ConfigDialog(BASE, WIDGET): > > > => no need to run make or similar to create python files each time you change > something in your ui files. > > load the plugin from the source folder (create a symbolic link from home QGIS > plugins dir to plugin source dir) > change something in the ui file > reload the plugin using "plugin reloader" and you immediately see the result > in QGIS. > > Regards > Arnaud Morvan > Ingénieur logiciel > Tél: +33 (0)4 58 48 20 32 <tel:+33%204%2058%2048%2020%2032> > > Camptocamp France SAS > Savoie Technolac, BP 352 > 73377 Le Bourget du Lac Cedex > http://www.camptocamp.com <http://www.camptocamp.com/> > Le 11/05/2017 à 12:44, Michal Zimmermann a écrit : >> Hi, >> I'm starting with qgis plugin development on ubuntu-based Mint OS (v 18.1 >> Serena). I created a very simple form in Qt Designer 4.8.7 and tried to >> convert it to python file with >> >> pyuic4 -d form.ui -o form.py >> >> This results in >> >> Traceback (most recent call last): >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/port_v2/invoke.py", line >> 34, in invoke >> exit_status = driver.invoke() >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/driver.py", line 59, in >> invoke >> self._generate() >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/driver.py", line 98, in >> _generate >> self._opts.resource_suffix) >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/__init__.py", line 173, >> in compileUi >> winfo = compiler.UICompiler().compileUi(uifile, pyfile, from_imports, >> resource_suffix) >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/Compiler/compiler.py", >> line 55, in __init__ >> CompilerCreatorPolicy()) >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/uiparser.py", line 170, >> in __init__ >> self.factory = QObjectCreator(creatorPolicy) >> File "/usr/lib/python2.7/dist-packages/PyQt4/uic/objcreator.py", line 94, >> in __init__ >> modinfo = plugin_locals["moduleInformation"]() >> File "<string>", line 52, in moduleInformation >> File "/usr/lib/python2.7/dist-packages/qgis/__init__.py", line 26, in >> <module> >> from qgis.PyQt import QtCore >> File "/usr/lib/python2.7/dist-packages/qgis/PyQt/QtCore.py", line 28, in >> <module> >> sip.setapi(api, 2) >> ValueError: API 'QDate' has already been set to version 1 >> >> If I change /usr/lib/python2.7/dist-packages/qgis/PyQt/QtCore.py line 28 to >> sip.setapi(api, 1), it works, QGIS starts with a following message though: >> >> Couldn't load PyQGIS. >> Python support will be disabled. >> >> Traceback (most recent call last): >> File "", line 1, in >> File "/usr/lib/python2.7/dist-packages/qgis/__init__.py", line 26, in >> from qgis.PyQt import QtCore >> File "/usr/lib/python2.7/dist-packages/qgis/PyQt/QtCore.py", line 28, in >> sip.setapi(api, 1) >> ValueError: API 'QDate' has already been set to version 2 >> >> Python version: >> 2.7.12 (default, Nov 19 2016, 06:48:10) >> [GCC 5.4.0 20160609] >> >> QGIS version: >> 2.18.7 'Las Palmas', 3b30e6a >> >> What exactly do I have to do to make the both sides work? >> >> -- >> Michal Zimmermann (zimmi) >> WWW: https://www.zimmi.cz <https://www.zimmi.cz/> >> >> _______________________________________________ >> QGIS-Developer mailing list >> QGIS-Developer@lists.osgeo.org <mailto:QGIS-Developer@lists.osgeo.org> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> <https://lists.osgeo.org/mailman/listinfo/qgis-developer> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> <https://lists.osgeo.org/mailman/listinfo/qgis-developer> > > > > -- > Michal Zimmermann (zimmi) > WWW: https://www.zimmi.cz > <https://www.zimmi.cz/>_______________________________________________ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org <mailto:QGIS-Developer@lists.osgeo.org> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > <https://lists.osgeo.org/mailman/listinfo/qgis-developer> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer