- Python tkinter canvas scale
- Geometry Management
- Binding Functions
- Working with Images in Tkinter
- Tkinter Advance
- Applications and Projects
- Introduction
- Geometry Management
- Binding Functions
- Working with Images in Tkinter
- Tkinter Advance
- Applications and Projects
- Python Tkinter Scale
- What is the Python Tkinter Scale?
- Options
- Creating Tkinter Scales
- Example 1
- Example 2
- Example 3
- Video Code
Python tkinter canvas scale
- Python | Creating a button in tkinter
- Python | Add style to tkinter button
- Python | Add image on a Tkinter button
- Python Tkinter – Label
- Python Tkinter | Create LabelFrame and add widgets to it
- RadioButton in Tkinter | Python
- Python Tkinter – Checkbutton Widget
- Python Tkinter – Canvas Widget
- Python Tkinter | Create different shapes using Canvas class
- Python Tkinter | Create different type of lines using Canvas class
- Python Tkinter | Moving objects using Canvas.move() method
- Combobox Widget in tkinter | Python
- maxsize() method in Tkinter | Python
- minsize() method in Tkinter | Python
- resizable() method in Tkinter | Python
- Python Tkinter – Entry Widget
- Tkinter – Read only Entry Widget
- Python Tkinter – Text Widget
- Python Tkinter – Message
- Python | Menu widget in Tkinter
- Python Tkinter – Menubutton Widget
- Python Tkinter – SpinBox
- Progressbar widget in Tkinter | Python
- Python-Tkinter Scrollbar
- Python Tkinter – ScrolledText Widget
- Python Tkinter – ListBox Widget
- Scrollable ListBox in Python-tkinter
- Python Tkinter – Frame Widget
- Scrollable Frames in Tkinter
- How to make a proper double scrollbar frame in Tkinter
- Python Tkinter – Scale Widget
- Hierarchical treeview in Python GUI application
- Python-Tkinter Treeview scrollbar
- Python Tkinter – Toplevel Widget
- Python | askopenfile() function in Tkinter
- Python | asksaveasfile() function in Tkinter
- Python – Tkinter askquestion Dialog
- Python Tkinter – MessageBox Widget
- Create a Yes/No Message Box in Python using tkinter
- Change the size of MessageBox – Tkinter
- Different messages in Tkinter | Python
- Change Icon for Tkinter MessageBox
- Python – Tkinter Choose color Dialog
- Popup Menu in Tkinter
Geometry Management
Binding Functions
Working with Images in Tkinter
Tkinter Advance
- Getting screen’s height and width using Tkinter | Python
- Python | How to dynamically change text of Checkbutton
- Python | focus_set() and focus_get() method
- Search String in Text using Python-Tkinter
- Autocomplete ComboBox in Python-Tkinter
- Autohiding Scrollbars using Python-tkinter
- Python Tkinter – Validating Entry Widget
- Tracing Tkinter variables in Python
- Python | setting and retrieving values of Tkinter variable
- Tkinter | Adding style to the input text using ttk.Entry widget
- Python | after method in Tkinter
- destroy() method in Tkinter | Python
- Text detection using Python
- Python | winfo_ismapped() and winfo_exists() in Tkinter
- Collapsible Pane in Tkinter | Python
- Creating a multiple Selection using Tkinter
- Creating Tabbed Widget With Python-Tkinter
- Open a new Window with a button in Python-Tkinter
- Cryptography GUI using python
Applications and Projects
- Python | Simple GUI calculator using Tkinter
- Create Table Using Tkinter
- Python | GUI Calendar using Tkinter
- File Explorer in Python using Tkinter
- Python | ToDo GUI Application using Tkinter
- Python: Weight Conversion GUI using Tkinter
- Python: Age Calculator using Tkinter
- Python | Create a GUI Marksheet using Tkinter
- Python | Loan calculator using Tkinter
- Python | Create a digital clock using Tkinter
- Make Notepad using Tkinter
- Color game using Tkinter in Python
- Python | Simple FLAMES game using Tkinter
- Simple registration form using Python Tkinter
- How to create a COVID19 Data Representation GUI?
Introduction
- Python | Creating a button in tkinter
- Python | Add style to tkinter button
- Python | Add image on a Tkinter button
- Python Tkinter – Label
- Python Tkinter | Create LabelFrame and add widgets to it
- RadioButton in Tkinter | Python
- Python Tkinter – Checkbutton Widget
- Python Tkinter – Canvas Widget
- Python Tkinter | Create different shapes using Canvas class
- Python Tkinter | Create different type of lines using Canvas class
- Python Tkinter | Moving objects using Canvas.move() method
- Combobox Widget in tkinter | Python
- maxsize() method in Tkinter | Python
- minsize() method in Tkinter | Python
- resizable() method in Tkinter | Python
- Python Tkinter – Entry Widget
- Tkinter – Read only Entry Widget
- Python Tkinter – Text Widget
- Python Tkinter – Message
- Python | Menu widget in Tkinter
- Python Tkinter – Menubutton Widget
- Python Tkinter – SpinBox
- Progressbar widget in Tkinter | Python
- Python-Tkinter Scrollbar
- Python Tkinter – ScrolledText Widget
- Python Tkinter – ListBox Widget
- Scrollable ListBox in Python-tkinter
- Python Tkinter – Frame Widget
- Scrollable Frames in Tkinter
- How to make a proper double scrollbar frame in Tkinter
- Python Tkinter – Scale Widget
- Hierarchical treeview in Python GUI application
- Python-Tkinter Treeview scrollbar
- Python Tkinter – Toplevel Widget
- Python | askopenfile() function in Tkinter
- Python | asksaveasfile() function in Tkinter
- Python – Tkinter askquestion Dialog
- Python Tkinter – MessageBox Widget
- Create a Yes/No Message Box in Python using tkinter
- Change the size of MessageBox – Tkinter
- Different messages in Tkinter | Python
- Change Icon for Tkinter MessageBox
- Python – Tkinter Choose color Dialog
- Popup Menu in Tkinter
Geometry Management
Binding Functions
Working with Images in Tkinter
Tkinter Advance
- Getting screen’s height and width using Tkinter | Python
- Python | How to dynamically change text of Checkbutton
- Python | focus_set() and focus_get() method
- Search String in Text using Python-Tkinter
- Autocomplete ComboBox in Python-Tkinter
- Autohiding Scrollbars using Python-tkinter
- Python Tkinter – Validating Entry Widget
- Tracing Tkinter variables in Python
- Python | setting and retrieving values of Tkinter variable
- Tkinter | Adding style to the input text using ttk.Entry widget
- Python | after method in Tkinter
- destroy() method in Tkinter | Python
- Text detection using Python
- Python | winfo_ismapped() and winfo_exists() in Tkinter
- Collapsible Pane in Tkinter | Python
- Creating a multiple Selection using Tkinter
- Creating Tabbed Widget With Python-Tkinter
- Open a new Window with a button in Python-Tkinter
- Cryptography GUI using python
Applications and Projects
- Python | Simple GUI calculator using Tkinter
- Create Table Using Tkinter
- Python | GUI Calendar using Tkinter
- File Explorer in Python using Tkinter
- Python | ToDo GUI Application using Tkinter
- Python: Weight Conversion GUI using Tkinter
- Python: Age Calculator using Tkinter
- Python | Create a GUI Marksheet using Tkinter
- Python | Loan calculator using Tkinter
- Python | Create a digital clock using Tkinter
- Make Notepad using Tkinter
- Color game using Tkinter in Python
- Python | Simple FLAMES game using Tkinter
- Simple registration form using Python Tkinter
- How to create a COVID19 Data Representation GUI?
Python Tkinter Scale
This Article is about the Python Tkinter Scale, what it is and how to use it.
What is the Python Tkinter Scale?
The Python Tkinter Scale widget is used to implement a graphical slider to the User interface giving the user the option of picking through a range of values. The Maximum and minimum values on the Scale can be set the programmer.
Options
Creating Tkinter Scales
Example 1
Here we have created two Tkinter scales, with different orientations. The first is by default VERTICAL, and we have set the second to HORIZONTAL.
We defined the range of the scales from 0 to 10 by setting these values in the from and to options respectively.
from tkinter import * root = Tk() root.geometry("200x200") frame = Frame(root) frame.pack() Scala = Scale(frame, from_=0, to=10) Scala.pack(padx=5, pady=5) Scala2 = Scale(frame, from_=0, to=10, orient=HORIZONTAL) Scala2.pack(padx=5, pady=5) root.mainloop()
Example 2
The following code has two new features. For one, it has the command option linked to the function val . Because of this, anytime the value of the slider is changed, that function will be called. The value of the slider is sent as a argument to the function.
Secondly, in the second Tkinter Scale we have set the resolution to 0.5. This allows us to pick a larger range of values than we can in the first Tkinter Scale. See the output to understand.
from tkinter import * def val(value): print(value) root = Tk() root.geometry("200x200") frame = Frame(root) frame.pack() Scala = Scale(frame, from_=0, to=10, command=val) Scala.pack(padx=5, pady=5) Scala2 = Scale(frame, from_=0, to=10, resolution = 0.5, command=val, orient=HORIZONTAL) Scala2.pack(padx=5, pady=5) root.mainloop()
This image was taken side by side the Standard Python IDE. You can see the output that is a result of us moving the slider.
Example 3
Sometimes you may want your scale to be labelled. Which is where the tick interval comes in. Setting it to 1, creates intervals of 1, in the range 0 to 10.
Make sure that the length of your Scale is large enough to hold that much text, else it will appear all jumbled up together. We’re also going to decrease the slider length, because it’s default size is pretty big.
from tkinter import * def val(value): print(value) root = Tk() root.geometry("200x200") frame = Frame(root) frame.pack() Scala = Scale(frame, from_=0, to=10, command=val) Scala.pack(padx=5, pady=5) Scala2 = Scale(frame, from_=0, to=10, length = 200, tickinterval = 1, command=val, orient=HORIZONTAL, sliderlength = 15) Scala2.pack(padx=5, pady=5) root.mainloop()
Video Code
import tkinter as tk class Window: def __init__(self, master): self.master = root # Frame self.frame = tk.Frame(self.master, width = 300, height = 200) self.frame.pack() # Scale self.scale = tk.Scale(self.frame, from_ = 0, to = 10, orient = tk.HORIZONTAL, command = self.ret, resolution = 1, digit = 2, tickinterval = 1, length = 200, sliderlength = 20, label = "My Scale", showvalue = 0, troughcolor = "blue") self.scale.place(x = 30, y= 30) # Button self.button = tk.Button(self.frame, text = "DISABLE the Scale", command = self.disable) self.button.place(x = 30, y = 100) def disable(self): self.scale.config(state = tk.DISABLED, troughcolor = "grey") def ret(self, value): print(value) root = tk.Tk() window = Window(root) root.mainloop()
This marks the end of the Python Tkinter Scale page. You can head back to the main Tkinter article using this link to learn about other widgets.
Any contributions or suggestions you may have are more than welcome. Feel free to ask any questions in the comments below.