Coverage for gws-app/gws/plugin/model_widget/geometry/__init__.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Geometry widget. 

2 

3Buttons to draw or edit the geometry of a ``geometry`` field. With 

4``isInline``, the widget is shown in the feature form; with ``withText``, the 

5geometry can also be edited as text. The widget is not shown in table views. 

6This is the default widget of ``geometry`` fields. 

7 

8Example:: 

9 

10 fields+ { 

11 name "geom" 

12 type "geometry" 

13 widget { type "geometry" isInline true withText true } 

14 } 

15""" 

16 

17import gws 

18import gws.base.model.widget 

19 

20 

21@gws.ext.config.modelWidget('geometry') 

22class Config(gws.base.model.widget.Config): 

23 """Buttons to draw or edit the feature geometry.""" 

24 

25 isInline: bool = False 

26 """Display the geometry widget in the form.""" 

27 withText: bool = False 

28 """Show a button to edit the geometry as text.""" 

29 

30 

31@gws.ext.props.modelWidget('geometry') 

32class Props(gws.base.model.widget.Props): 

33 isInline: bool 

34 withText: bool 

35 

36 

37@gws.ext.object.modelWidget('geometry') 

38class Object(gws.base.model.widget.Object): 

39 """Geometry widget object.""" 

40 

41 supportsTableView = False 

42 

43 def props(self, user): 

44 return gws.u.merge( 

45 super().props(user), 

46 isInline=self.cfg('isInline', default=False), 

47 withText=self.cfg('withText', default=False), 

48 )