Reputation: 124
I wanted to start a new project with python, so i saw this so it looked cool so i wanted to give it a try, but i dont know how to make that scroller, all i found online was ways to make it scroll through text and documents, but not to control input, could someone help me make something like this?
and is there a way to make it display the number of characters above the scroller?
this is what i got online, i dont know if its the same thing as what i want
scrollbar1 = Scrollbar(master1, bg="green")
scrollbar1.pack( side = RIGHT, fill = Y )
Upvotes: 1
Views: 526
Reputation: 2431
You are looking for Scale widget . Please check this snippet and also please refer https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/scale.html for more details.
from tkinter import *
root = Tk()
root.geometry("100x100")
v1 = DoubleVar()
s1 = Scale( root, variable = v1,from_ = 1, to = 100,orient = HORIZONTAL)
l3 = Label(root, text = "Horizontal Scaler")
l1 = Label(root)
s1.pack(anchor = CENTER)
l3.pack()
l1.pack()
root.mainloop()
Edit
If you want the scale value dynamically on moving the pointer of scale and without triggering any button then please check this snippet along with screenshot.
from tkinter import *
def get_value(val):
scale_val = "Scale value= " + str(val)
label.config(text = scale_val)
root = Tk()
root.geometry("100x150")
v1 = DoubleVar()
s1 = Scale( root, variable = v1,from_ = 1, to = 100,orient = HORIZONTAL, command=get_value)
l3 = Label(root, text = "Horizontal Scaler")
l1 = Label(root)
s1.pack(anchor = CENTER)
l3.pack()
l1.pack()
label = Label(root)
label.pack()
root.mainloop()
Upvotes: 2