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

1"""Static legend. 

2 

3Uses an image file as the legend. 

4 

5Example:: 

6 

7 legend { 

8 type "static" 

9 path "/data/legend.png" 

10 } 

11""" 

12 

13import gws 

14import gws.lib.image 

15import gws.base.legend 

16 

17 

18@gws.ext.config.legend('static') 

19class Config(gws.base.legend.Config): 

20 """Legend from a static image file.""" 

21 

22 path: gws.FilePath 

23 """Path to the legend image file.""" 

24 

25 

26@gws.ext.object.legend('static') 

27class Object(gws.base.legend.Object): 

28 """Static legend.""" 

29 

30 path: str 

31 """Path to the image file.""" 

32 

33 def configure(self): 

34 self.path = self.cfg('path') 

35 

36 def render(self, args=None): 

37 img = gws.lib.image.from_path(self.path) 

38 return gws.LegendRenderOutput(image=img, size=img.size())