Im making a paint program and I keep running into this error however if I change where event.x /event.y are defined the same error comes up but with a different subroutine
here is the code:
class paint:
def __init__(self,root,canvas):
self.root = root
self.mouse_press = False #mouse isnt being pressed
self.canvas = canvas
self.canvas.bind('<ButtonPress-1>',self.MouseDown) # when left click is pressed / down the subroutine MouseDown is opened
self.canvas.bind('<ButtonRelease-1>',self.MouseUp)#when left click is relased open the MouseUp subroutine
def MouseDown(self,event):
self.x = event.x
self.y = event.y
self.mouse_press = True # mouse is pressed
self.poll() #calls the coodinates subroutine
def MouseUp(self,event):
self.poll()
self.mouse_press = False
self.root.after_cancel(self.after_id)
def poll(self):
if self.mouse_press:
canvas.create_oval(self.x,self.y, self.x+10, self.y+10 , fill = '#f6f65a',outline = '#f6f65a')
self.after_id = self.root.after(10,self.MouseDown)
def colour_pick():
colour_choose = colorchooser.askcolor()[1] #opens a colour picker and picks the colour
print(colour_choose)
return(colour_choose)
how I am calling the class
p = paint(root,canvas)
root.mainloop()
the error I keep getting:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 839, in callit
func(*args)
TypeError: paint.MouseDown missing 1 required positional argument: 'event'