Rudy
Rudy

Reputation: 467

Giving a tkinter scale widget a 'jump' function

I have a tkinter.scale widget that is executing a command each time the scale is moved. My problem is that whenever i move the mouse it will execute the command rapidly as the scale changes position.

Similar to the tkinter.scrollbar widget that has the config parameter 'jump', I want my scale to execute the code ONLY when the mouse button is released, and not every time there is a change in the scale.

Upvotes: 0

Views: 636

Answers (1)

Henry Yik
Henry Yik

Reputation: 22503

You said ONLY when the mouse button is released - so why don't bind to the button release event?

import tkinter as tk

root = tk.Tk()

def something(event=None):
    print ("hi")

s = tk.Scale(root,from_=0, to=50)
s.pack()
s.bind("<ButtonRelease-1>",something)

root.mainloop()

Upvotes: 3

Related Questions