My objective is to generate a python plug-in for QGIS that will open a CSV and define a field within the table to display as a map tip.

I'm trying to achieve this task and have got stuck on trying to set the layer properties using python, rather than opening the 'layer properties' dialog, selecting the Display tab and entering HTML expression...

the HTML expression I'm trying to insert into the layer properties is:

field1= '<b>\"title\"</b><br/>\n'+'[%CONCAT(\'<img src=\"\',\"file\",\'\" width=\"400\"></img>\')%]'

where "title" and "file" are fields within the CSV, giving rise to:

[%CONCAT('<img src="',"file",'" width="400"></img>')%]

This gives me the right HTML to slot into a relevant place - and it works when I use this manually, but I'm now lost trying to find how to change the layer properties using python...

There seems to be a function called setDisplayAttributes but I can't really follow the API description well enough to understand whether it is the correct function and I can't find any examples using this function.

I'm a toddler with Python but probably pre-pubescent with QGIS (Version 2.8 on Windows 10).



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.