while using th epython library turtle i am getting the error
"error"
AttributeError module ColabTurtle.Turtle has no attribute undo
"code"
import ColabTurtle.Turtle as t
t.initializeTurtle(initial_speed=5)
t.speed(1)
t.forward(100)
t.undo()
while using th epython library turtle i am getting the error
"error"
AttributeError module ColabTurtle.Turtle has no attribute undo
"code"
import ColabTurtle.Turtle as t
t.initializeTurtle(initial_speed=5)
t.speed(1)
t.forward(100)
t.undo()
You're using a stripped down version of Turtle, that doesn't include an undo buffer.
https://github.com/tolgaatam/ColabTurtle/blob/master/ColabTurtle/Turtle.py
You'd have to roll your own undo function that parses global svg_lines_string
and removes the last entry. Not about to test that, but it would be something like this:
def undo():
global svg_lines_string
last_entry = t .svg_lines_string .rfind('<line x1=')
t .svg_lines_string = t .svg_lines_string[ :last_entry ]
t ._updateDrawing()
undo()
Alternatively, you could use t.clear()
and then redraw everything up to that point, exluding your last step.
If it supports multiple turtles on the screen at once, then you could use a secondary turtle that only draws those commands you wish to discard. This way, when you do a t2.clear()
, it won't erase your original turtle.
[ :last_entry ]
–
Terminology © 2022 - 2024 — McMap. All rights reserved.