A Scale widget is used to display the progress or amount on a sliding scale. The Scale can be adjusted to change the value as desired.


A Scale can be constructed using the following:

scale = Gtk.Scale(orientation, adjustment)

The orientation parameter should be set to either Gtk.Orientation.HORIZONTAL or Gtk.Orientation.VERTICAL. The adjustment parameter should be set to specify the minimum, maximum and incremental values.


A Scale can be oriented in two directions; horizontal and vertical. To change the orientation after construction:


The orientation parameter should be set with the same values as those at construction.

By default, the Scale shows the value above the slider. This can be configured using:


When draw_value is set to False, the value is not displayed above the slider.

To change the position of where the value is displayed, use:


The position value should be set to one of the following; Gtk.PositionType.TOP, Gtk.PositionType.BOTTOM, Gtk.PositionType.LEFT or Gtk.PositionType.RIGHT. By default Gtk.PositionType.TOP is used.

To adjust the number of decimal points displayed when drawing the value:


The digits parameter should be an integer figure, with 1 meaning 1.0, 2 meaning 1.00, etc. Setting the number of digits also causes the value to be rounded off.

To highlight the change between the initial value and the current value, the following method can be used to indicate the difference:


In some cases it may be useful to place a marker on the Scale to identify a particular position:

scale.add_mark(value, position, markup)

The value parameter should specify the value at which the mark is to be drawn. The position can also be specified, with one of the values previously mentioned accepted. The markup parameter can be set to a string of text which is also displayed on the scale next to the mark. This parameter is optional however.

All the marks can be cleared from the Scale with:



The common signals of a Scale widget are:

"format-value" (value)

The "format value" signal allows the way the value is displayed.


Below is an example of a Scale:

#!/usr/bin/env python

from gi.repository import Gtk
import random

class Scale(Gtk.Window):
    def __init__(self):
        self.set_default_size(200, 200)
        self.connect("destroy", Gtk.main_quit)

        grid = Gtk.Grid()

        value = random.randint(0, 100)
        adjustment = Gtk.Adjustment(value, 0, 100, 1, 10, 0)

        self.scale = Gtk.Scale(orientation=Gtk.Orientation.VERTICAL, adjustment=adjustment)
        grid.attach(self.scale, 0, 0, 2, 1)

        buttonAdd = Gtk.Button(label="Add Mark")
        buttonAdd.connect("clicked", self.on_add_mark_clicked)
        grid.attach(buttonAdd, 0, 1, 1, 1)

        buttonClear = Gtk.Button(label="Clear Marks")
        buttonClear.connect("clicked", self.on_clear_marks_clicked)
        grid.attach(buttonClear, 1, 1, 1, 1)

        radiobuttonVertical = Gtk.RadioButton(group=None, label="Vertical Scale")
        radiobuttonVertical.orientation = 0
        radiobuttonVertical.connect("toggled", self.on_orientation_clicked)
        grid.attach(radiobuttonVertical, 0, 3, 2, 1)

        radiobuttonHorizontal = Gtk.RadioButton(group=radiobuttonVertical, label="Horizontal Scale")
        radiobuttonHorizontal.orientation = 1
        radiobuttonHorizontal.connect("toggled", self.on_orientation_clicked)
        grid.attach(radiobuttonHorizontal, 0, 2, 2, 1)

    def on_add_mark_clicked(self, button):
        value = self.scale.get_value()
        self.scale.add_mark(value, Gtk.PositionType.LEFT, "Mark")

    def on_clear_marks_clicked(self, button):

    def on_orientation_clicked(self, radiobutton):
        if radiobutton.orientation == 0:

window = Scale()


Download: Scale