Gtk.Layout


Gtk.Layout — Infinite scrollable area containing child widgets and/or custom drawing

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Layout

See also:

Gtk.DrawingArea, Gtk.ScrolledWindow


Functions:

Description:

and/or custom drawing GtkLayout is similar to Gtk.DrawingArea in that it’s a blank slate and doesn’t do anything but paint a blank background by default. It's different in that it supports scrolling natively (you can add it to a Gtk.ScrolledWindow), and it can contain child widgets, since it’s a GtkContainer. However if you’re just going to draw, a Gtk.DrawingArea is a better choice since it has lower overhead.

When handling expose events on a Gtk.Layout, you must draw to GTK_LAYOUT (layout)->bin_window, rather than to GTK_WIDGET (layout)->window, as you would for a drawing area.


Function Details:

new()

new (hadjustment:Gtk.Adjustment=None, vadjustment:Gtk.Adjustment=None) -> Gtk.Widget

Creates a new Gtk.Layout. Unless you have a specific adjustmentyou’d like the layout to use for scrolling, pass None forhadjustment and vadjustment.

  • Returns: a new Gtk.Layout

put()

put (self, child_widget:Gtk.Widget, x:int, y:int)

Adds child_widget to layout, at position (x,y).layout becomes the new parent container of child_widget.


move()

move (self, child_widget:Gtk.Widget, x:int, y:int)

Moves a current child of layout to a new position.


set_size()

set_size (self, width:int, height:int)

Sets the size of the scrollable area of the layout.


get_size()

get_size (self) -> width:int, height:int

Gets the size that has been set on the layout, and that determinesthe total extents of the layout’s scrollbar area. SeeGtk.Layout:set_size().


get_hadjustment()

get_hadjustment (self) -> Gtk.Adjustment

Gtk.Layout:get_hadjustment has been deprecated since version 3.0 and should not be used in newly-written code. Use `Gtk.Scrollable:get_hadjustment()This function should only be called after the layout has beenplaced in aGtk.ScrolledWindowor otherwise configured forscrolling. It returns theGtk.Adjustmentused for communicationbetween the horizontal scrollbar andlayout. SeeGtk.ScrolledWindow,Gtk.Scrollbar,Gtk.Adjustment` for details.

  • Returns: horizontal scroll adjustment.

get_vadjustment()

get_vadjustment (self) -> Gtk.Adjustment

Gtk.Layout:get_vadjustment has been deprecated since version 3.0 and should not be used in newly-written code. Use `Gtk.Scrollable:get_vadjustment()This function should only be called after the layout has beenplaced in aGtk.ScrolledWindowor otherwise configured forscrolling. It returns theGtk.Adjustmentused for communicationbetween the vertical scrollbar andlayout. SeeGtk.ScrolledWindow,Gtk.Scrollbar,Gtk.Adjustment` for details.

  • Returns: vertical scroll adjustment.

set_hadjustment()

set_hadjustment (self, adjustment:Gtk.Adjustment=None)

Gtk.Layout:set_hadjustment has been deprecated since version 3.0 and should not be used in newly-written code. Use `Gtk.Scrollable:set_hadjustment()Sets the horizontal scroll adjustment for the layout. SeeGtk.ScrolledWindow,Gtk.Scrollbar,Gtk.Adjustment` for details.


set_vadjustment()

set_vadjustment (self, adjustment:Gtk.Adjustment=None)

Gtk.Layout:set_vadjustment has been deprecated since version 3.0 and should not be used in newly-written code. Use `Gtk.Scrollable:set_vadjustment()Sets the vertical scroll adjustment for the layout. SeeGtk.ScrolledWindow,Gtk.Scrollbar,Gtk.Adjustment` for details.


get_bin_window()

get_bin_window (self) -> Gdk.Window

Retrieve the bin window of the layout used for drawing operations.

  • Returns: a GdkWindow.

  • Since: 2.14


Example:

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

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

        layout = Gtk.Layout()
        self.add(layout)

        button = Gtk.Button(label="Button 1")
        layout.put(button, 40, 60)
        button = Gtk.Button(label="Button 2")
        layout.put(button, 120, 95)

window = Layout()
window.show_all()

Gtk.main()

results matching ""

    No results matching ""