MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _undo

Method _undo

tools/python-3.11.9-amd64/Lib/turtle.py:3608–3638  ·  view source on GitHub ↗

Does the main part of the work for undo()

(self, action, data)

Source from the content-addressed store, hash-verified

3606
3607
3608 def _undo(self, action, data):
3609 """Does the main part of the work for undo()
3610 """
3611 if self.undobuffer is None:
3612 return
3613 if action == "rot":
3614 angle, degPAU = data
3615 self._rotate(-angle*degPAU/self._degreesPerAU)
3616 dummy = self.undobuffer.pop()
3617 elif action == "stamp":
3618 stitem = data[0]
3619 self.clearstamp(stitem)
3620 elif action == "go":
3621 self._undogoto(data)
3622 elif action in ["wri", "dot"]:
3623 item = data[0]
3624 self.screen._delete(item)
3625 self.items.remove(item)
3626 elif action == "dofill":
3627 item = data[0]
3628 self.screen._drawpoly(item, ((0, 0),(0, 0),(0, 0)),
3629 fill="", outline="")
3630 elif action == "beginfill":
3631 item = data[0]
3632 self._fillitem = self._fillpath = None
3633 if item in self.items:
3634 self.screen._delete(item)
3635 self.items.remove(item)
3636 elif action == "pen":
3637 TPen.pen(self, data[0])
3638 self.undobuffer.pop()
3639
3640 def undo(self):
3641 """undo (repeatedly) the last turtle action.

Callers 1

undoMethod · 0.95

Calls 8

_rotateMethod · 0.95
clearstampMethod · 0.95
_undogotoMethod · 0.95
_drawpolyMethod · 0.80
penMethod · 0.80
popMethod · 0.45
_deleteMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected