Could anyone advise how to retrieve and update a Label
widget with the value from a Scale
widget in Python? Currently it shows a very large real number. I have tried to type cast the value but this only works when I print to idle. I tried slider.get()
but the label is blank. Also tried int(slider.get())
which works when I print to idle.
from tkinter import *
from tkinter import ttk
root = Tk()
root.title("Playing with Scales")
mainframe = ttk.Frame(root, padding="24 24 24 24")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
slider = IntVar()
ttk.Scale(mainframe, from_=0, to_=100, length=300, variable=slider).grid(column=1, row=4, columnspan=5)
ttk.Label(mainframe, textvariable=slider).grid(column=1, row=0, columnspan=5)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
root.mainloop()
Here you can see the very large real value: