Write text at the current turtle position. Arguments: arg -- info, which is to be written to the TurtleScreen move (optional) -- True/False align (optional) -- one of the strings "left", "center" or right" font (optional) -- a triple (fontname, fontsize, font
(self, arg, move=False, align="left", font=("Arial", 8, "normal"))
| 3538 | return end |
| 3539 | |
| 3540 | def write(self, arg, move=False, align="left", font=("Arial", 8, "normal")): |
| 3541 | """Write text at the current turtle position. |
| 3542 | |
| 3543 | Arguments: |
| 3544 | arg -- info, which is to be written to the TurtleScreen |
| 3545 | move (optional) -- True/False |
| 3546 | align (optional) -- one of the strings "left", "center" or right" |
| 3547 | font (optional) -- a triple (fontname, fontsize, fonttype) |
| 3548 | |
| 3549 | Write text - the string representation of arg - at the current |
| 3550 | turtle position according to align ("left", "center" or right") |
| 3551 | and with the given font. |
| 3552 | If move is True, the pen is moved to the bottom-right corner |
| 3553 | of the text. By default, move is False. |
| 3554 | |
| 3555 | Example (for a Turtle instance named turtle): |
| 3556 | >>> turtle.write('Home = ', True, align="center") |
| 3557 | >>> turtle.write((0,0), True) |
| 3558 | """ |
| 3559 | if self.undobuffer: |
| 3560 | self.undobuffer.push(["seq"]) |
| 3561 | self.undobuffer.cumulate = True |
| 3562 | end = self._write(str(arg), align.lower(), font) |
| 3563 | if move: |
| 3564 | x, y = self.pos() |
| 3565 | self.setpos(end, y) |
| 3566 | if self.undobuffer: |
| 3567 | self.undobuffer.cumulate = False |
| 3568 | |
| 3569 | @contextmanager |
| 3570 | def poly(self): |