VolumeButton

A VolumeButton is used to control the volume within an application. It is very similar to a ScaleButton.

Constructor

The VolumeButton can be constructed using:

volumebutton = Gtk.VolumeButton()

Methods

To retrieve the current value from the VolumeButton use:

value = volumebutton.get_value()

Alternatively, to set a particular value run:

volumebutton.set_value(value)

The value argument must be an integer value between 0 and 100.

Example

Below is an example of a VolumeButton:

#!/usr/bin/env python3

from gi.repository import Gtk

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

        grid = Gtk.Grid()
        self.add(grid)

        volumebutton = Gtk.VolumeButton()
        volumebutton.connect("value-changed", self.on_volume_button_changed)
        grid.attach(volumebutton, 0, 0, 1, 1)

    def on_volume_button_changed(self, volumebutton, value):
        print("VolumeButton value: %0.2f" % (value))

window = VolumeButton()
window.show_all()

Gtk.main()

Download: VolumeButton