class circle_color:
def __init__(self):
self.circle_red = canvas.create_oval(10, 160, 140, 290, fill="red")
self.circle_blue = canvas.create_oval(10, 10, 140, 140, fill="blue")
def circle_blue_add(self):
return self.circle_blue
def circle_red_add(self):
return self.circle_red
but_circle_blue_add = Button(panel_with_button, text="Add Blue Circle", width=20, command=circle_color.circle_blue_add)
but_circle_blue_add.place(x=10, y=10)
but_circle_blue_del = Button(panel_with_button, text="Add Red Circle", width=20, command=circle_color.circle_blue_add)
but_circle_blue_del.place(x=10, y=50)'
This Error
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Fleshka\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
return self.func(*args)
TypeError: circle_blue_add() missing 1 required positional argument: 'self'
I need to draw two figure one blue and red with oop programming. But I do not understand why it doesn't work
circle_blue_addmethod is expecting that you pass itself(an instance of the class), and you didn't. Please expand your code sample into an MCVE so we can determine the changes that would be most appropriate for your program.