A simple function to make a default svg icon for the widgets such icons can be replaced later with a good one
(name, view_w=1, view_h=0.6)
| 442 | |
| 443 | |
| 444 | def default_icon(name, view_w=1, view_h=0.6): |
| 445 | """ |
| 446 | A simple function to make a default svg icon for the widgets |
| 447 | such icons can be replaced later with a good one |
| 448 | """ |
| 449 | icon = gui.Svg(width=50,height=30) |
| 450 | icon.set_viewbox(-view_w/2,-view_h/2,view_w,view_h) |
| 451 | text = gui.SvgText(0,0,name) |
| 452 | text.attributes['textLength'] = "100%" |
| 453 | text.attributes['lengthAdjust'] = "spacingAndGlyphs" |
| 454 | text.style['font-size'] = "0.2px" |
| 455 | text.style['text-anchor'] = "middle" |
| 456 | stroke_width = 0.01 |
| 457 | rect = gui.SvgRectangle(-view_w/2+stroke_width,-view_h/2+stroke_width,view_w-stroke_width*2,view_h-stroke_width*2) |
| 458 | rect.set_fill("none") |
| 459 | rect.set_stroke(0.01,'black') |
| 460 | icon.append([rect, text]) |
| 461 | return icon |
| 462 | |
| 463 | |
| 464 | class WidgetHelper(gui.HBox): |
no test coverage detected