Gtk.ScaleButton


Gtk.ScaleButton — A button which pops up a scale

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Button
                        ╰── Gtk.ScaleButton
                            ╰── Gtk.VolumeButton

Functions:


Signals:

  • “popdown” (button, user_data)
  • “popup” (button, user_data)
  • “value-changed” (button, value, user_data)

Description:

Gtk.ScaleButton provides a button which pops up a scale widget.

This kind of widget is commonly used for volume controls in multimedia applications, and GTK+ provides a Gtk.VolumeButton subclass that is tailored for this use case.


Function Details:

new()

new (size:int, min:float, max:float, step:float, icons:list=None) -> Gtk.Widget

Creates a Gtk.ScaleButton, with a range between min and max, witha stepping of step.

  • Returns: a new Gtk.ScaleButton

  • Since: 2.12


set_adjustment()

set_adjustment (self, adjustment:Gtk.Adjustment)

Sets the Gtk.Adjustment to be used as a modelfor the Gtk.ScaleButton’s scale.See `Gtk.Range:set_adjustment()` for details.

  • Since: 2.12

set_icons()

set_icons (self, icons:list)

Sets the icons to be used by the scale button.For details, see the “icons” property.

  • Since: 2.12

set_value()

set_value (self, value:float)

Sets the current value of the scale; if the value is outsidethe minimum or maximum range values, it will be clamped to fitinside them. The scale button emits the “value-changed”signal if the value changes.

  • Since: 2.12

get_adjustment()

get_adjustment (self) -> Gtk.Adjustment

Gets the Gtk.Adjustment associated with the Gtk.ScaleButton’s scale.See `Gtk.Range:get_adjustment()` for details.

  • Returns: the adjustment associated with the scale.

  • Since: 2.12


get_value()

get_value (self) -> float

Gets the current value of the scale button.

  • Returns: current value of the scale button

  • Since: 2.12


get_popup()

get_popup (self) -> Gtk.Widget

Retrieves the popup of the Gtk.ScaleButton.

  • Returns: the popup of the Gtk.ScaleButton.

  • Since: 2.14


get_plus_button()

get_plus_button (self) -> Gtk.Button

Retrieves the plus button of the Gtk.ScaleButton.

  • Returns: the plus button of the Gtk.ScaleButton as a Gtk.Button.

  • Since: 2.14


get_minus_button()

get_minus_button (self) -> Gtk.Button

Retrieves the minus button of the Gtk.ScaleButton.

  • Returns: the minus button of the Gtk.ScaleButton as a Gtk.Button.

  • Since: 2.14


Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class ScaleButton(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)

        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()
window.show_all()

Gtk.main()

results matching ""

    No results matching ""