Coverage for gws-app/gws/plugin/legend/html/__init__.py: 0%
16 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""HTML legend.
3Renders an HTML template to a PNG image, which is used as the legend.
5Example::
7 legend {
8 type "html"
9 template {
10 type "html"
11 text "<p>Legend</p>"
12 }
13 }
14"""
16import gws
17import gws.base.legend
18import gws.lib.image
19import gws.lib.mime
22@gws.ext.config.legend('html')
23class Config(gws.base.legend.Config):
24 """Legend rendered from an HTML template."""
26 template: gws.ext.config.template
27 """Template for the HTML legend."""
30@gws.ext.object.legend('html')
31class Object(gws.base.legend.Object):
32 """HTML legend."""
34 template: gws.Template
35 """Template for the legend."""
37 def configure(self):
38 self.template = self.create_child(gws.ext.object.template, self.cfg('template'))
40 def render(self, args=None):
41 # @TODO return html legends as html
42 res = self.template.render(gws.TemplateRenderInput(
43 args=args,
44 mimeOut=gws.lib.mime.PNG))
45 img = gws.lib.image.from_path(res.contentPath)
46 return gws.LegendRenderOutput(image=img, size=img.size())