Gtk.Constraint

g GObject.Object GObject.Object Gtk.Constraint Gtk.Constraint GObject.Object->Gtk.Constraint

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (target, target_attribute, relation, source, source_attribute, multiplier, constant, strength)

class

new_constant (target, target_attribute, relation, constant, strength)

get_constant ()

get_multiplier ()

get_relation ()

get_source ()

get_source_attribute ()

get_strength ()

get_target ()

get_target_attribute ()

is_attached ()

is_constant ()

is_required ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

constant

float

r/w/co

multiplier

float

r/w/co

relation

Gtk.ConstraintRelation

r/w/co

source

Gtk.ConstraintTarget

r/w/co

source-attribute

Gtk.ConstraintAttribute

r/w/co

strength

int

r/w/co

target

Gtk.ConstraintTarget

r/w/co

target-attribute

Gtk.ConstraintAttribute

r/w/co

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.Constraint(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.ConstraintClass

GtkConstraint describes a constraint between attributes of two widgets, expressed as a linear equation.

The typical equation for a constraint is:

``

target.target_attr = source.source_attr × multiplier + constant

``

Each GtkConstraint is part of a system that will be solved by a [class`Gtk`.ConstraintLayout] in order to allocate and position each child widget or guide.

The source and target, as well as their attributes, of a GtkConstraint instance are immutable after creation.

classmethod new(target, target_attribute, relation, source, source_attribute, multiplier, constant, strength)[source]
Parameters:
Returns:

the newly created constraint

Return type:

Gtk.Constraint

Creates a new constraint representing a relation between a layout attribute on a source and a layout attribute on a target.

classmethod new_constant(target, target_attribute, relation, constant, strength)[source]
Parameters:
Returns:

the newly created constraint

Return type:

Gtk.Constraint

Creates a new constraint representing a relation between a layout attribute on a target and a constant value.

get_constant()[source]
Returns:

a constant factor

Return type:

float

Retrieves the constant factor added to the source attributes’ value.

get_multiplier()[source]
Returns:

a multiplication factor

Return type:

float

Retrieves the multiplication factor applied to the source attribute’s value.

get_relation()[source]
Returns:

a relation type

Return type:

Gtk.ConstraintRelation

The order relation between the terms of the constraint.

get_source()[source]
Returns:

the source of the constraint

Return type:

Gtk.ConstraintTarget or None

Retrieves the [iface`Gtk`.ConstraintTarget] used as the source for the constraint.

If the source is set to NULL at creation, the constraint will use the widget using the [class`Gtk`.ConstraintLayout] as the source.

get_source_attribute()[source]
Returns:

the source’s attribute

Return type:

Gtk.ConstraintAttribute

Retrieves the attribute of the source to be read by the constraint.

get_strength()[source]
Returns:

the strength value

Return type:

int

Retrieves the strength of the constraint.

get_target()[source]
Returns:

a GtkConstraintTarget

Return type:

Gtk.ConstraintTarget or None

Retrieves the [iface`Gtk`.ConstraintTarget] used as the target for the constraint.

If the targe is set to NULL at creation, the constraint will use the widget using the [class`Gtk`.ConstraintLayout] as the target.

get_target_attribute()[source]
Returns:

the target’s attribute

Return type:

Gtk.ConstraintAttribute

Retrieves the attribute of the target to be set by the constraint.

is_attached()[source]
Returns:

TRUE if the constraint is attached

Return type:

bool

Checks whether the constraint is attached to a [class`Gtk`.ConstraintLayout], and it is contributing to the layout.

is_constant()[source]
Returns:

TRUE if the constraint is a constant relation

Return type:

bool

Checks whether the constraint describes a relation between an attribute on the [property`Gtk`.Constraint:target] and a constant value.

is_required()[source]
Returns:

True if the constraint is required

Return type:

bool

Checks whether the constraint is a required relation for solving the constraint layout.

Property Details

Gtk.Constraint.props.constant
Name:

constant

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The constant value to be added to the [property`Gtk`.Constraint:source-attribute].

Gtk.Constraint.props.multiplier
Name:

multiplier

Type:

float

Default Value:

1.0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The multiplication factor to be applied to the [property`Gtk`.Constraint:source-attribute].

Gtk.Constraint.props.relation
Name:

relation

Type:

Gtk.ConstraintRelation

Default Value:

Gtk.ConstraintRelation.EQ

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The order relation between the terms of the constraint.

Gtk.Constraint.props.source
Name:

source

Type:

Gtk.ConstraintTarget

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The source of the constraint.

The constraint will set the [property`Gtk`.Constraint:target-attribute] property of the target using the [property`Gtk`.Constraint:source-attribute] property of the source.

Gtk.Constraint.props.source_attribute
Name:

source-attribute

Type:

Gtk.ConstraintAttribute

Default Value:

Gtk.ConstraintAttribute.NONE

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The attribute of the [property`Gtk`.Constraint:source] read by the constraint.

Gtk.Constraint.props.strength
Name:

strength

Type:

int

Default Value:

1001001000

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The strength of the constraint.

The strength can be expressed either using one of the symbolic values of the [enum`Gtk`.ConstraintStrength] enumeration, or any positive integer value.

Gtk.Constraint.props.target
Name:

target

Type:

Gtk.ConstraintTarget

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The target of the constraint.

The constraint will set the [property`Gtk`.Constraint:target-attribute] property of the target using the [property`Gtk`.Constraint:source-attribute] property of the source widget.

Gtk.Constraint.props.target_attribute
Name:

target-attribute

Type:

Gtk.ConstraintAttribute

Default Value:

Gtk.ConstraintAttribute.NONE

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The attribute of the [property`Gtk`.Constraint:target] set by the constraint.