Hi,
Sorry y hadn't been enought specific. The problem was on the images URLs.
I fixed it with this function:
def fix_qml_rel_urls(self, url):
"""
Replaces the QML URLs with plugin relative URLs
:return:
"""
plugin_dir = os.path.dirname(os.path.realpath(__file__))
with open(url, 'r') as fd:
data = fd.read()
f = etree.fromstring(data)
for r in f.xpath('//qgis/renderer-v2/symbols/symbol/layer/prop[@k="
name"]'):
val = r.get('v')
parent = r.getparent()
parent.remove(r)
rel_url = os.path.join(plugin_dir, val)
r.set('v', rel_url)
parent.append(r)
t = etree.tostring(f, pretty_print=True)
tmp_url = tempfile.NamedTemporaryFile(suffix='.qml', delete=False)
tmp_url.write(t)
tmp_url.close()
return tmp_url.name
I'm sure that this don't work on all the types of symbols but perhaps is
useful for someone
After patch the style I loaded it.
Best reggards.
Xavier Barnada
2016-10-13 14:27 GMT+02:00 Tom Chadwin <[email protected]>:
> Hi Xavier
>
> This should give you the path to your plugin's installation folder:
>
> os.path.dirname(os.path.realpath(__file__))
>
> Hope this is what you need.
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> View this message in context: http://osgeo-org.1560.x6.
> nabble.com/Including-style-on-a-Qgis-plugin-tp5290553p5290560.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [email protected]
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
_______________________________________________
Qgis-developer mailing list
[email protected]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer