Tkinter

Scale Tkinter | Python 3

In this tutorial, we are going to see how to use the Scale widget in Tkinter. The Scale widget allows the user to select a numerical value by moving a slider button along a scale. You can control the minimum and maximum values, as well as the resolution.
 


 
 

Syntax: Scale widget in Tkinter

Here is the syntax to create this widget:

s = Scale ( master, option = value, ... )

 

Parameters:
  • master : This represents the parent window.
  • options : Options can be used as comma-separated key-value. See the following example:

 

 

Example:
from tkinter import *
  
def sel():
   selected = "Value = " + str(var.get())
   label.config(text = selected)

gui = Tk()
var = DoubleVar()
s = Scale(gui, from_=0, to=100, variable = var)
s.pack(anchor=CENTER)

btn = Button(gui, text="Get Value", command=sel)
btn.pack(anchor=CENTER)

label = Label(gui)
label.pack()
gui.mainloop()

Output:


 
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *