pythonzelle-graphics

GUI errors. Can't undraw 'Rectangle' objects


I imported a GUI library and I can't 'undraw' any objects that are a 'Rectangle'. I attached the link to the library I'm using and an example of what the error looks like. Thanks for any and all help given.

https://mcsp.wartburg.edu//zelle/python/graphics.py

from graphics import *

win = GraphWin("Test", 200, 200)

rect = Rectangle(Point(50, 50), Point(150,150)).draw(win)
stop = win.getMouse()
rect.undraw(win)

This is the error that I'm getting from IDLE


Solution

  • The problem is this line:

    rect.undraw(win)
    

    the rectangle is already associated with win so you don't supply that as an argument to undraw(). Instead simply do:

    rect.undraw()