MCPcopy Index your code
hub / github.com/python/cpython / _write

Method _write

Lib/turtle.py:583–595  ·  view source on GitHub ↗

Write txt at pos in canvas with specified font and color. Return text item and x-coord of right bottom corner of text's bounding box.

(self, pos, txt, align, font, pencolor)

Source from the content-addressed store, hash-verified

581 return self.cv.cget("bg")
582
583 def _write(self, pos, txt, align, font, pencolor):
584 """Write txt at pos in canvas with specified font
585 and color.
586 Return text item and x-coord of right bottom corner
587 of text's bounding box."""
588 x, y = pos
589 x = x * self.xscale
590 y = y * self.yscale
591 anchor = {"left":"sw", "center":"s", "right":"se" }
592 item = self.cv.create_text(x-1, -y, text = txt, anchor = anchor[align],
593 fill = pencolor, font = font)
594 x0, y0, x1, y1 = self.cv.bbox(item)
595 return item, x1-1
596
597 def _onclick(self, item, fun, num=1, add=None):
598 """Bind fun to mouse-click event on turtle.

Callers

nothing calls this directly

Calls 2

create_textMethod · 0.80
bboxMethod · 0.45

Tested by

no test coverage detected