Skip to content

Gtk.ConstraintGuide

class — extends GObject.Object, ConstraintTarget

An invisible layout element in a GtkConstraintLayout.

The GtkConstraintLayout treats guides like widgets. They can be used as the source or target of a GtkConstraint.

Guides have a minimum, maximum and natural size. Depending on the constraints that are applied, they can act like a guideline that widgets can be aligned to, or like flexible space.

Unlike a GtkWidget, a GtkConstraintGuide will not be drawn.

Constructors

new

@classmethod
def new(cls) -> ConstraintGuide

Creates a new GtkConstraintGuide object.

Methods

get_max_size

def get_max_size(self) -> tuple[int, int]

Gets the maximum size of guide.

get_min_size

def get_min_size(self) -> tuple[int, int]

Gets the minimum size of guide.

get_name

def get_name(self) -> str | None

Retrieves the name set using ConstraintGuide.set_name.

get_nat_size

def get_nat_size(self) -> tuple[int, int]

Gets the natural size of guide.

get_strength

def get_strength(self) -> ConstraintStrength

Retrieves the strength set using ConstraintGuide.set_strength.

set_max_size

def set_max_size(self, width: int, height: int) -> None

Sets the maximum size of guide.

If guide is attached to a GtkConstraintLayout, the constraints will be updated to reflect the new size.

Parameters:

  • width — the new maximum width, or -1 to not change it
  • height — the new maximum height, or -1 to not change it

set_min_size

def set_min_size(self, width: int, height: int) -> None

Sets the minimum size of guide.

If guide is attached to a GtkConstraintLayout, the constraints will be updated to reflect the new size.

Parameters:

  • width — the new minimum width, or -1 to not change it
  • height — the new minimum height, or -1 to not change it

set_name

def set_name(self, name: str | None = ...) -> None

Sets a name for the given GtkConstraintGuide.

The name is useful for debugging purposes.

Parameters:

  • name — a name for the guide

set_nat_size

def set_nat_size(self, width: int, height: int) -> None

Sets the natural size of guide.

If guide is attached to a GtkConstraintLayout, the constraints will be updated to reflect the new size.

Parameters:

  • width — the new natural width, or -1 to not change it
  • height — the new natural height, or -1 to not change it

set_strength

def set_strength(self, strength: ConstraintStrength | int) -> None

Sets the strength of the constraint on the natural size of the given GtkConstraintGuide.

Parameters:

  • strength — the strength of the constraint

Properties

max_height

max_height: int  # read/write

The maximum height of the guide.

max_width

max_width: int  # read/write

The maximum width of the guide.

min_height

min_height: int  # read/write

The minimum height of the guide.

min_width

min_width: int  # read/write

The minimum width of the guide.

name

name: str  # read/write

A name that identifies the GtkConstraintGuide, for debugging.

nat_height

nat_height: int  # read/write

The preferred, or natural, height of the guide.

nat_width

nat_width: int  # read/write

The preferred, or natural, width of the guide.

strength

strength: ConstraintStrength | int  # read/write

The GtkConstraintStrength to be used for the constraint on the natural size of the guide.