Skip to content Skip to sidebar Skip to footer

How Can I Disable Horizontal Scrolling In A Tkinter Listbox? (python 3)

Say in Tkinter you have a listbox of a certain size within a window. Then let's say you add a string to that listbox that is larger than that size. If you highlight this element an

Solution 1:

The auto-scrolling is triggered by the mouse leaving the listbox while the button is pressed. Perhaps the simplest solution is to prevent that behavior by creating your own binding that returns "break":

listbox.bind("<B1-Leave>", lambda event: "break")

Note: this will also prevent the vertical auto-scrolling. If you want to keep the vertical auto-scrolling than you'll have to write a more complex function that will only return "break" if the mouse is to the left or right of the listbox.

Post a Comment for "How Can I Disable Horizontal Scrolling In A Tkinter Listbox? (python 3)"