Gtk.Scrollbar
Gtk.Scrollbar — A Scrollbar
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Range
╰── Gtk.Scrollbar
├── Gtk.HScrollbar
╰── Gtk.VScrollbar
Functions:
- new
(orientation:Gtk.Orientation, adjustment:Gtk.Adjustment=None) -> Gtk.Widget
Description:
The Gtk.Scrollbar
widget is a horizontal or vertical scrollbar, depending on the value of the GtkOrientable::orientation property.
The position of the thumb in a scrollbar is controlled by the scroll adjustments. See Gtk.Adjustment for the fields in an adjustment - for GtkScrollbar, the Gtk.Adjustment:value field represents the position of the scrollbar, which must be between the Gtk.Adjustment:lower field scrollable area. The Gtk.Adjustment:step-increment and step down (using the small stepper arrows) or page down (using for example the Page Down
key).
Function Details:
new()
new (orientation:Gtk.Orientation, adjustment:Gtk.Adjustment=None) -> Gtk.Widget
Creates a new scrollbar with the given orientation.
Returns: the new
Gtk.Scrollbar
.Since: 3.0
Example:
#/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class Window(Gtk.Window):
def __init__(self):
super().__init__()
self.set_title("Scrollbar")
self.set_default_size(200, 200)
self.connect("destroy", Gtk.main_quit)
grid = Gtk.Grid()
self.add(grid)
layout = Gtk.Layout()
layout.set_size(800, 500)
layout.set_vexpand(True)
layout.set_hexpand(True)
button = Gtk.Button(label="Button 1")
layout.put(button, 300, 400)
button = Gtk.Button(label="Button 2")
layout.put(button, 150, 50)
button = Gtk.Button(label="Button 3")
layout.put(button, 720, 470)
grid.attach(layout, 0, 0, 1, 1)
vadjustment = layout.get_vadjustment()
hadjustment = layout.get_hadjustment()
vscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.VERTICAL,
adjustment=vadjustment)
grid.attach(vscrollbar, 1, 0, 1, 1)
hscrollbar = Gtk.Scrollbar(orientation=Gtk.Orientation.HORIZONTAL,
adjustment=hadjustment)
grid.attach(hscrollbar, 0, 1, 1, 1)
window = Window()
window.show_all()
Gtk.main()