I'm trying to bind mouse motions (pressed/unpressed) with some methods. I tried to handle mouse motions while mouse button is pressed with '' and the other with just ''. I found that when I just have ..bind('', somemethod1), somemethod1 is called regardless of mouse button press, but when I also have ..bind('', somemethod2), somemethod1 is not called when mouse button was pressed. Adding 'add='+'' didn't seem to work.
def bind_mouse(self):
self.canvas.bind('<Button1-Motion>', self.on_button1_motion1)
self.canvas.bind('<Motion>', self.on_mouse_unpressed_motion1)
def on_button1_motion1(self, event):
print(self.on_button1_motion1.__name__)
def on_mouse_unpressed_motion1(self, event):
print(self.on_mouse_unpressed_motion1.__name__)
So I instead modified the on_button1_motion1 method as below:
def on_button1_motion1(self, event):
print(self.on_button1_motion1.__name__)
self.canvas.event_generate('<Motion>')
But when I tried this, I got this runtime error:
Traceback (most recent call last): File "D:/save/WORKSHOP/py/tkinter/Blueprints/Pycrosoft Paintk/view.py", line 107, in root.mainloop() File "C:\Users\smj\AppData\Local\Programs\Python\Python35\lib\tkinter__init__.py", line 1131, in mainloop self.tk.mainloop(n) RecursionError: maximum recursion depth exceeded
Can anyone explain to me why this is happening? I know I can solve this problem by just calling on_mouse_unpressed_motion1 method inside on_button1_motion1 method instead of generating an event, but I'd like to know why the other way doesn't work. Thanks