[QGIS-Developer] Bug with python macro on project load

Tim Sutton tim at kartoza.com
Wed Aug 14 13:13:33 PDT 2019


Thanks Bo! @Mario can you confirm which behaviour you replicated? The exception when calling traceback.print_exception() failed
or my dodgy code simply failing with a nice exception message as Bo demonstrated (which is expected behaviour).

Regards

Tim
 

> On 14 Aug 2019, at 20:25, Bo Victor Thomsen <bo.victor.thomsen at gmail.com> wrote:
> 
> Hi Tim !  (Greetings from Denmark :-) 
> 
> On Windows 8.1 64 bit and QGIS 3.8.1 64 bit: 
> 
> I've modified your python code a little bit:
> 
> from qgis.core import QgsProject
> from qgis.utils import iface
> 
> def openProject():
>     layers = QgsProject.instance().mapLayersByName('kommune')
>     layer = layers[0]
>     iface.showAttributeTable(layer)
>     
> 
> def saveProject():
>     pass
> 
> def closeProject():
>     pass
> 
> It works after enabling macro's. (You'll have to change the layer name back to your original layer name)
> 
> -- 
> Med venlig hilsen / Kind regards
> 
> Bo Victor Thomsen
> 
> 
> 
> 
> Den 14-08-2019 kl. 17:21 skrev Tim Sutton:
>> Hi
>> 
>> Oh thanks for the feedback!
>> 
>> Regards
>> 
>> Tim
>> 
>>> On 14 Aug 2019, at 13:27, Mario Baranzini <mario at opengis.ch <mailto:mario at opengis.ch>> wrote:
>>> 
>>> Hi Tim, 
>>> I have exactly the same error with QGIS 3.8.0 on Archlinux.
>>> 
>>> Cheers
>>> 
>>> On Wed, 14 Aug 2019 at 10:13, Tim Sutton <tim at kartoza.com <mailto:tim at kartoza.com>> wrote:
>>> Hi All
>>> 
>>> I am running into a bug on macOS using QGIS 3.8 using the project load python hook [1] and was curious:
>>> 
>>> 1) Can anybody replicate this on other operating systems
>>> 2) Does the macro run *after* layers have been loaded in the project or before?  Former seems more logical to me but you should never assume to much eh? :-)
>>> 
>>> Thanks
>>> 
>>> Tim
>>> 
>>> 
>>> 
>>> [1] https://github.com/qgis/QGIS/issues/31235 <https://github.com/qgis/QGIS/issues/31235>
>>>>>> 
>>> 
>>> <KartozaNewLogoThumbnail.jpg>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Tim Sutton
>>> 
>>> Co-founder: Kartoza
>>> Ex Project chair: QGIS.org <http://qgis.org/>
>>> 
>>> Visit http://kartoza.com <http://kartoza.com/> to find out about open source:
>>> 
>>> Desktop GIS programming services
>>> Geospatial web development
>>> GIS Training
>>> Consulting Services
>>> 
>>> Skype: timlinux 
>>> IRC: timlinux on #qgis at freenode.net <http://freenode.net/>
>>> 
>>> I'd love to connect. Here's my calendar link <https://calendly.com/timlinux> to make finding time easy.
>>> 
>>> _______________________________________________
>>> QGIS-Developer mailing list
>>> QGIS-Developer at lists.osgeo.org <mailto:QGIS-Developer at 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>
>>> 
>>> -- 
>>> Mario Baranzini
>>> mario at opengis.ch  <mailto:mario at opengis.ch>
>>> +41 (0)78 733 01 59 <tel:+41787330159>
>>>  <http://www.opengis.ch/>
>>>> 
>> 
>> <KartozaNewLogoThumbnail.jpg>
>> 
>> 
>> 
>> 
>> 
>> 
>> Tim Sutton
>> 
>> Co-founder: Kartoza
>> Ex Project chair: QGIS.org <http://qgis.org/>
>> 
>> Visit http://kartoza.com <http://kartoza.com/> to find out about open source:
>> 
>> Desktop GIS programming services
>> Geospatial web development
>> GIS Training
>> Consulting Services
>> 
>> Skype: timlinux 
>> IRC: timlinux on #qgis at freenode.net <http://freenode.net/>
>> 
>> I'd love to connect. Here's my calendar link <https://calendly.com/timlinux> to make finding time easy.
>> 
>> 
>> 
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org <mailto:QGIS-Developer at 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 at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

—









Tim Sutton

Co-founder: Kartoza
Ex Project chair: QGIS.org

Visit http://kartoza.com <http://kartoza.com/> to find out about open source:

Desktop GIS programming services
Geospatial web development
GIS Training
Consulting Services

Skype: timlinux 
IRC: timlinux on #qgis at freenode.net

I'd love to connect. Here's my calendar link <https://calendly.com/timlinux> to make finding time easy.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190814/fcd1bf6f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KartozaNewLogoThumbnail.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190814/fcd1bf6f/attachment-0001.jpg>


More information about the QGIS-Developer mailing list