<p dir="ltr">Il 28/nov/2016 20:32, "Nyall Dawson" <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> ha scritto:<br>
><br>
><br>
><br>
> On 29 Nov 2016 12:55 AM, "Alessandro Pasotti" <<a href="mailto:apasotti@gmail.com">apasotti@gmail.com</a>> wrote:<br>
>><br>
>> On Mon, Nov 28, 2016 at 3:44 PM, Matthias Kuhn <<a href="mailto:matthias@opengis.ch">matthias@opengis.ch</a>> wrote:<br>
>>><br>
>>> Hi Alessandro,<br>
>>><br>
>>> QApplication is part of PyQt, did you check if it also changed if you<br>
>>> run a non-QGIS pyqt application?<br>
>><br>
>><br>
>><br>
>> Yes, it seems so:<br>
>><br>
>> >>> from PyQt5.QtWidgets import QApplication, QWidget<br>
>> >>> a = QApplication([])<br>
>> >>> a.argv()<br>
>><br>
>> Traceback (most recent call last):<br>
>>   File "<stdin>", line 1, in <module><br>
>><br>
>> AttributeError: 'QApplication' object has no attribute 'argv'<br>
><br>
><br>
> Shouldn't that be QApplication.arguments()?<br>
><br>
> <a href="http://doc.qt.io/qt-5/qcoreapplication.html#arguments">http://doc.qt.io/qt-5/qcoreapplication.html#arguments</a><br>
><br>
> There's no QApplication::argv member.<br>
><br>
> Nyall<br>
></p>
<p dir="ltr">Thanks, arguments() works the same as argv() for Qt5.</p>
<p dir="ltr">Do you by chance know where does argv member come from in PyQt4? I couldn't find it in the Qt 4.8 docs, that's why I was confused. Was it a PyQt addition? <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qcoreapplication.html#argv">http://pyqt.sourceforge.net/Docs/PyQt4/qcoreapplication.html#argv</a><br></p>
<p dir="ltr">>><br>
>><br>
>> In [2]: import sys<br>
>>    ...: from PyQt4 import Qt<br>
>>    ...:  <br>
>>    ...: a = Qt.QApplication(sys.argv)<br>
>>    ...: <br>
>><br>
>> In [3]: a.argv()<br>
>> Out[3]: ['/usr/local/bin/ipython']<br>
>><br>
>><br>
>> Now I wonder if this is a PyQt bug or something changed in Qt itself<br>
>><br>
>> Is there anything we can do to get the argv/argc in a python script running inside QGIS?<br>
>><br>
>> This is needed by the testing environment in <a href="https://github.com/boundlessgeo/qgis-testing-environment-docker/blob/master/qgis_testrunner.py#L150">https://github.com/boundlessgeo/qgis-testing-environment-docker/blob/master/qgis_testrunner.py#L150</a><br>
>> fortunately, there are some workarounds.<br>
>><br>
>>  <br>
>>><br>
>>><br>
>>> Matthias<br>
>>><br>
>>> On 11/28/2016 03:35 PM, Alessandro Pasotti wrote:<br>
>>> > Hi,<br>
>>> ><br>
>>> > the following code is working fine in 2.x but not in master:<br>
>>> ><br>
>>> >>>> QgsApplication.instance().argv()<br>
>>> > Traceback (most recent call last):<br>
>>> >   File "/usr/lib/python3.5/code.py", line 91, in runcode<br>
>>> >     exec(code, self.locals)<br>
>>> >   File "<input>", line 1, in <module><br>
>>> > AttributeError: 'QApplication' object has no attribute 'argv'<br>
>>> ><br>
>>> ><br>
>>> > I looked at the sip file but I did not find the reason why it's now<br>
>>> > failing, any idea what has changed in this regard?<br>
>>> ><br>
>>> ><br>
>>> > --<br>
>>> > Alessandro Pasotti<br>
>>> > w3:   <a href="http://www.itopen.it">www.itopen.it</a> <<a href="http://www.itopen.it">http://www.itopen.it</a>><br>
>>> ><br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > Qgis-developer mailing list<br>
>>> > <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
>>> > List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>>> > Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>>> ><br>
>>> _______________________________________________<br>
>>> Qgis-developer mailing list<br>
>>> <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
>>> List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>>> Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>><br>
>><br>
>><br>
>><br>
>> -- <br>
>> Alessandro Pasotti<br>
>> w3:   <a href="http://www.itopen.it">www.itopen.it</a><br>
>><br>
>> _______________________________________________<br>
>> Qgis-developer mailing list<br>
>> <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
>> List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>> Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
><br>
></p>