QGIS layer: import CSV and set 'Display HTML Map Tip' using python

المشرف العام

Administrator
طاقم الإدارة
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= '\"title\"
\n'+'[%CONCAT(\'<img src=\"\',\"file\",\'\" width=\"400\">\')%]'where "title" and "file" are fields within the CSV, giving rise to:

"title"
[%CONCAT('
')%]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).



أكثر...
 
أعلى