'graphwin problems: 'list' object has no attribute 'onSaveClick'

I have (probably) a stupid error on my Python source code, then I search for a simple example to verify if it is my error not and I verify that this simple example/test does not work:

from graphics import *

if __name__ == '__main__':

    def main():
        win = GraphWin('My Graphics', 250, 250) # specifies graphics window size 250x250
        g = Point(125, 125) # creates a Point object at x=125 y=125
        g.draw(win) # draws to the graphics window
        win.getMouse() # keep window up
        win.close()

    main()

It stops after g.draw(win) with this error:

AttributeError: 'list' object has no attribute 'onSaveClick'

I followed the code and I found that the error could be on class GraphWin(tk.Canvas): in the method:

def addItem(self, item):
    self.items.onSaveClick(item)

So it could be a bug. Or have I misunderstand something?



Solution 1:[1]

In Python 3.8.6 graphics.py has an error inside, addItem() method has self.onSave(item) instead of self.items.append(item) so updating graphics.py to the 5.0 release solves the problem as pointed out by https://stackoverflow.com/users/355230/martineau

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Massimo Manca