So, here is the code I have, and as I run it, the value of the slider bar appears above the slider, I wonder is there a way to get that value out? Maybe let a=that value. ;)
from Tkinter import *
control = Tk()
control.geometry("350x200+100+50")
scale = Scale(control,orient=HORIZONTAL,length=300,width=20,sliderlength=10,from_=0,to=1000,tickinterval=100)
scale.pack()
control.mainloop()
The Scale widget is used to implement the graphical slider to the python application so that the user can slide through the range of values shown on the slider and select the one among them. We can control the minimum and maximum values along with the resolution of the scale.
Tkinter IntVar() FunctionA variable defined using IntVar() function holds integer data where we can set integer data and can retrieve it as well using getter and setter methods.
Use the ttk. Progressbar(container, orient, length, mode) to create a progressbar. Use the indeterminate mode when the program cannot accurately know the relative progress to display. Use the determinate mode if you know how to measure the progress accurately.
To get the value as it is modified, associate a function with the parameter command
. This function will receive the current value, so you just work with it. Also note that in your code you have cline3 = Scale(...).pack()
. cline3
is always None in this case, since that is what pack()
returns.
import Tkinter
def print_value(val):
print val
root = Tkinter.Tk()
scale = Tkinter.Scale(orient='horizontal', from_=0, to=128, command=print_value)
scale.pack()
root.mainloop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With