Why Do I get an error when I try to get tkinter slider value? Why Do I get an error when I try to get tkinter slider value? tkinter tkinter

Why Do I get an error when I try to get tkinter slider value?


Simplifying your 2nd example you need to have an argument handled in your function that is trying to get the value of Scale.

Scale is already passing an argument so you dont need to write a lambda to manage this.

Simple do this:

import tkinter as tkdef blurring(value):    print(value)root = tk.Tk()scale = tk.Scale(root, orient='horizontal', from_=0, to=128, command=blurring)scale.pack()root.mainloop()

Results:

enter image description here


In the command option for blur_slide, change it either:

...command = lambda: av_blue(k) # where k is the value you pass to the function

EDIT

The lambda function is used here to pass the argument k when the slider is clicked or changes position.

If k is a computed value, then the computation has to be done in a different function (placed under the command option) as:

...command = precomputedef precomute():    # calculate k here    av_blur(k)

or change the function defintion to:

def av_blur():    # your code here