Hi! nice work!
I'm trying calysto turtle with ipywidgets, and I would like to clear the canvas.
How can I do that?
Here is my code
import ipywidgets as widgets
from IPython.display import display, clear_output
from calysto.graphics import *
sides = widgets.IntSlider(min=3, max=10, description="Sides")
button = widgets.Button(description="Draw!")
canvas = Canvas(size=(400, 400))
turtle = Turtle(canvas, (200, 20), 0)
def draw_polygon(button):
global sizes, canvas, turtle
for _ in range(sides.value):
turtle.forward(50)
turtle.right(360/sides.value)
clear_output(wait=True)
display(sides, button, canvas)
button.on_click(draw_polygon)
display(sides, button, canvas)
If I use canvas.clear() then I get
ValueError: <Polygon [(-10, 5), (0, 0), (-10, -5), (-5, 0)]> is not in list
Thanks!
Hi! nice work!
I'm trying calysto turtle with ipywidgets, and I would like to clear the canvas.
How can I do that?
Here is my code
If I use
canvas.clear()then I getThanks!