[Qgis-user] Python form logic on attribute table open

Thomas Colley it087 at neath-porttalbot.gov.uk
Tue May 3 04:50:05 PDT 2016


Hi Matthias

I am using global variables. In what way do they cause problems?

Is it expected behaviour for the Python logic to be used when the attribute table is opened?

I know what is causing the Python error. I am performing an intersect query to populate an attribute. When I open the attribute table the first feature in the attribute table is being passed to the Python form object but it doesn’t include the geometry. This gives AttributeError: 'NoneType' object has no attribute 'intersects'.

I have no need for any of the Python logic on opening of the attribute table, although I can see the advantage if it was open in form view.

Hope this makes sense, if you have any more details on the global variables I’d be grateful.

Thanks

Tom

From: Qgis-user [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Matthias Kuhn
Sent: 03 May 2016 09:45
To: qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] Python form logic on attribute table open

Hi Tom,

Are you using global variables? They often lead to troubles in this context.

Matthias
On 05/03/2016 10:42 AM, Thomas Colley wrote:
Hi

I have a Python init function bound to an attribute form. This is working great using the identify tool to open a feature form but is throwing an error when I open the layer’s attribute table.

Is there any way I can check in the Python whether a feature form has been opened or the attribute table. I have no need for the logic when opening the attribute table.

I’ve found QgsAttributeEditorContext that looks like it might do the trick but I can’t work out how to access it.

Any advice would be appreciated.

Thanks

Tom




_______________________________________________

Qgis-user mailing list

Qgis-user at lists.osgeo.org<mailto:Qgis-user at lists.osgeo.org>

List info: http://lists.osgeo.org/mailman/listinfo/qgis-user

Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user



--

Matthias Kuhn

OPENGIS.ch - https://www.opengis.ch

Spatial • (Q)GIS • PostGIS • Open Source
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20160503/9321aaa1/attachment.html>


More information about the Qgis-user mailing list