Coverage for gws-app/gws/plugin/legend/static/__init__.py: 0%
14 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"""Static legend.
3Uses an image file as the legend.
5Example::
7 legend {
8 type "static"
9 path "/data/legend.png"
10 }
11"""
13import gws
14import gws.lib.image
15import gws.base.legend
18@gws.ext.config.legend('static')
19class Config(gws.base.legend.Config):
20 """Legend from a static image file."""
22 path: gws.FilePath
23 """Path to the legend image file."""
26@gws.ext.object.legend('static')
27class Object(gws.base.legend.Object):
28 """Static legend."""
30 path: str
31 """Path to the image file."""
33 def configure(self):
34 self.path = self.cfg('path')
36 def render(self, args=None):
37 img = gws.lib.image.from_path(self.path)
38 return gws.LegendRenderOutput(image=img, size=img.size())