Search code examples
pythontkinter

How to disable mouse wheel in python tkinter with certain condition?


self.loginWindow.bind("<MouseWheel>",
                         lambda event: self.canvas.yview_scroll(int(-1 * (event.delta / 120)), "units"))

This was supposed to enable the scroll wheel in my tkinter project, but the problem is i want to stop that in a specific condition. How to do that ?

I tried to make it this way

self.loginWindow.bind(None)

but it is not working


Solution

  • You can Try

    if (anything):
       self.loginWindow.bind("<MouseWheel>",
                              lambda event: None)
    else:
         (otherwise)
    

    This will stop the mouse wheel events