[Qgis-developer] Compiling ui files with custom widgets creates wrong imports

Lauri Kajan lauri.kajan at gmail.com
Sat Sep 19 02:11:11 PDT 2015


Hi all,

I found this same problem.

pyuic4 on osgeo4w environment doesn't fix this. Still the compiled py file
tries to import QgsFieldComboBox from qgsfieldcombobox.

Is this an error in osgeo4w environment? Possibly some paths are missing
from PYTHONPATH or PATH?
At least qgis package and its gui module couldn't be found by python of
osgeo4w.

I tried to create a qgis.bat to %OSGEO4W_ROOT%\etc\ini with the following
commands:
  set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis-dev\python
  PATH %OSGEO4W_ROOT%\apps\qgis-dev\bin;%PATH%
After that qgis.gui is imported fine in python but still pyuic4 can't
find QgsFieldComboBox
from correct location.

The actual problem might be that
C:\OSGeo4W64\apps\qgis-dev\python\PyQt4\uic\widget-plugins\qgis_customwidgets.py
file is not found by pyuic4.
After I copied that file
to C:\OSGeo4W64\apps\Python27\Lib\site-packages\PyQt4\uic\widget-plugins
everything works ok.


Is this a osgeo4w bug or could this be fixed by us?
Should the qgis postinstall bat copy qgis_customwidgets.py file to the
right place?



Thanks,

Lauri


On Thu, Aug 6, 2015 at 12:03 PM, Anita Graser <anitagraser at gmx.at> wrote:

>
>
> On Thu, Aug 6, 2015 at 10:54 AM, Denis Rouzaud <denis.rouzaud at gmail.com>
> wrote:
>
>> Here is an example of a Makefile compiling ui files
>> https://github.com/3nids/quickfinder/blob/master/Makefile#L52
>>
>> it's the line with pyuic4 which does the job!
>>
>
>
> ​Thanks Denis! I'll try that on Win later.
>
> I'd still be interested if there is a solution to ensure that dynamic ui
> loading on Win finds the right libraries for custom widgets.
>
> Best wishes,
> Anita​
>
>
>
>
>
>
>>
>>
>>
>>
>> On 08/06/2015 10:33 AM, Anita Graser wrote:
>>
>>
>>
>> On Thu, Aug 6, 2015 at 10:10 AM, Denis Rouzaud <denis.rouzaud at gmail.com>
>> wrote:
>>
>>> Never used, I would think it would work directly.
>>>
>>
>> ​ According to the plugin author the plugin with uic.loadUiTypes works on
>> Linux but it certainly does not work on Windows.​
>>>>
>>> But why not adding a new rule to the makefile to compile the ui?
>>>
>>
>> ​If that's necessary to get custom widgets work on all platforms, why
>> not. But I don't know where to start to make that work.
>>
>> Best wishes.
>> Anita​
>>
>>
>>
>>
>>
>>
>>>
>>>
>>>
>>>
>>> On 08/06/2015 10:06 AM, Anita Graser wrote:
>>>
>>>
>>>
>>> On Thu, Aug 6, 2015 at 9:44 AM, Denis Rouzaud <
>>> <denis.rouzaud at gmail.com>denis.rouzaud at gmail.com> wrote:
>>>
>>>> Well, how is compiled the UI file?
>>>>
>>>
>>> ​The plugin builder creates a template that uses uic.loadUiType
>>>
>>> FORM_CLASS, _ = uic.loadUiType(os.path.join(
>>> os.path.dirname(__file__), 'cartogram_dialog_base.ui'))
>>>>>> ​So the UI is compiled automatically when the plugin starts in QGIS.
>>>
>>> Best wishes,
>>> Anita​
>>>
>>>
>>>
>>>
>>>
>>>> Usually, it is done prior to deployment using pyuic4
>>>>
>>>> If pyuic4 was run without the proper python path, you won't have any
>>>> error at compilation but the plugin won't work if it contains QGIS widgets.
>>>>
>>>> Was pyuic4 run in an Osgeo shell?
>>>>
>>>>
>>>>
>>>>
>>>> On 08/06/2015 09:39 AM, Anita Graser wrote:
>>>>
>>>>
>>>>
>>>> On Thu, Aug 6, 2015 at 9:24 AM, Denis Rouzaud <
>>>> <denis.rouzaud at gmail.com>denis.rouzaud at gmail.com> wrote:
>>>>
>>>>> You need to have qgis lib in your python path.
>>>>> On windows, that would be C:\OSGeo4W\apps\qgis-dev\python\qgis
>>>>> To check this, just do "from qgis.gui import *" in python. If you
>>>>> don't have an error, then pyuic4 will work properly.
>>>>>
>>>>
>>>> ​My point is that the plugin needs to work out of the box - and it
>>>> doesn't.
>>>> Usually all paths are set correctly on Win in the OSGeo shell. Only in
>>>> this case there is an issue.
>>>>
>>>> Best wishes,
>>>> Anita
>>>>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150919/3c09abaf/attachment.html>


More information about the Qgis-developer mailing list