A ScaleButton provides a Scale which can be accessed via clicking a button which provides a popup menu showing the scale.


The ScaleButton can be constructed using:

scalebutton = Gtk.ScaleButton(size, min_value, max_value, step, icons)

The size parameter indicates the size of the icons within the ScaleButton. The constant should be set to one of the following; Gtk.IconSize.INVALID, Gtk.IconSize.MENU, Gtk.IconSize.SMALL_TOOLBAR, Gtk.IconSize.LARGE_TOOLBAR, Gtk.IconSize.BUTTON, Gtk.IconSize.DND, or Gtk.IconSize.DIALOG. The min_value, max_value and, step values should be set to integers which indicate the minimum and maximum values on the scale, along with the increase and decrease in the value when the + or - buttons are pressed. Finally, the icons parameter should be a tuple, which indicates the icons shown when the scale changes.


To retrieve the value from the ScaleButton run:

value = scalebutton.get_value()

Alternatively, to set the value use:


If an Adjustment is required to be used with the ScaleButton, this can be specified with:


The apply icons to the ScaleButton which are adjusted when the scale changes, these can be specified using:


The icons value is a tuple, which lists the icons that should be shown on the ScaleButton.


Below is an example of a ScaleButton:

#!/usr/bin/env python3

from gi.repository import Gtk

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

        grid = Gtk.Grid()

        scalebutton = Gtk.ScaleButton()
        scalebutton.set_icons(("gtk-go-down", "gtk-go-up"))
        scalebutton.connect("value-changed", self.on_scale_button_changed)
        grid.attach(scalebutton, 0, 0, 1, 1)

    def on_scale_button_changed(self, scalebutton, value):
        print("ScaleButton value: %0.2f" % (value))

window = ScaleButton()


Download: ScaleButton