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

Method _undo

Lib/turtle.py:3742–3772  ·  view source on GitHub ↗

Does the main part of the work for undo()

(self, action, data)

Source from the content-addressed store, hash-verified

3740
3741
3742 def _undo(self, action, data):
3743 """Does the main part of the work for undo()
3744 """
3745 if self.undobuffer is None:
3746 return
3747 if action == "rot":
3748 angle, degPAU = data
3749 self._rotate(-angle*degPAU/self._degreesPerAU)
3750 self.undobuffer.pop()
3751 elif action == "stamp":
3752 stitem = data[0]
3753 self.clearstamp(stitem)
3754 elif action == "go":
3755 self._undogoto(data)
3756 elif action in ["wri", "dot"]:
3757 item = data[0]
3758 self.screen._delete(item)
3759 self.items.remove(item)
3760 elif action == "dofill":
3761 item = data[0]
3762 self.screen._drawpoly(item, ((0, 0),(0, 0),(0, 0)),
3763 fill="", outline="")
3764 elif action == "beginfill":
3765 item = data[0]
3766 self._fillitem = self._fillpath = None
3767 if item in self.items:
3768 self.screen._delete(item)
3769 self.items.remove(item)
3770 elif action == "pen":
3771 TPen.pen(self, data[0])
3772 self.undobuffer.pop()
3773
3774 def undo(self):
3775 """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