annotate lib/goocanvas_compat.py @ 2032:0cd765253fde

switch to pnpm
author drewp@bigasterisk.com
date Thu, 07 Apr 2022 01:17:24 -0700
parents 2d2be076754f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1058
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
1 from gi.repository import GooCanvas
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
2
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
3 def Points(pts):
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
4 cp = GooCanvas.CanvasPoints.new(len(pts))
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
5 for i, (x, y) in enumerate(pts):
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
6 cp.set_point(i, x, y)
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
7 return cp
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
8
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
9 def polyline_new_line(parent, x0=None, y0=None, x1=None, y1=None, points=None, **props):
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
10 p = GooCanvas.CanvasPolyline()
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
11 p.set_property('parent', parent)
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
12 if x0 is not None or points is not None:
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
13 pts = points or Points([(x0, y0), (x1, y1)])
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
14 p.set_property('points', pts)
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
15 for k, v in props.items():
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
16 p.set_property(k, v)
2d2be076754f forgot to add goocanvas code
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
17 return p