Gtk.Constraint¶
class — extends GObject.Object
Describes a constraint between attributes of two widgets, expressed as a linear equation.
The typical equation for a constraint is:
Each GtkConstraint is part of a system that will be solved by a
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.
Constructors¶
new¶
@classmethod
def new(cls, target: ConstraintTarget | None, target_attribute: ConstraintAttribute | int, relation: ConstraintRelation | int, source: ConstraintTarget | None, source_attribute: ConstraintAttribute | int, multiplier: float, constant: float, strength: int) -> Constraint
Creates a new constraint representing a relation between a layout attribute on a source and a layout attribute on a target.
Parameters:
target— the target of the constrainttarget_attribute— the attribute oftargetto be setrelation— the relation equivalence betweentarget_attributeandsource_attributesource— the source of the constraintsource_attribute— the attribute ofsourceto be readmultiplier— a multiplication factor to be applied tosource_attributeconstant— a constant factor to be added tosource_attributestrength— the strength of the constraint
new_constant¶
@classmethod
def new_constant(cls, target: ConstraintTarget | None, target_attribute: ConstraintAttribute | int, relation: ConstraintRelation | int, constant: float, strength: int) -> Constraint
Creates a new constraint representing a relation between a layout attribute on a target and a constant value.
Parameters:
target— a the target of the constrainttarget_attribute— the attribute oftargetto be setrelation— the relation equivalence betweentarget_attributeandconstantconstant— a constant factor to be set ontarget_attributestrength— the strength of the constraint
Methods¶
get_constant¶
Retrieves the constant factor added to the source attributes' value.
get_multiplier¶
Retrieves the multiplication factor applied to the source attribute's value.
get_relation¶
The order relation between the terms of the constraint.
get_source¶
Retrieves the 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 ConstraintLayout as the source.
get_source_attribute¶
Retrieves the attribute of the source to be read by the constraint.
get_strength¶
Retrieves the strength of the constraint.
get_target¶
Retrieves the 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 ConstraintLayout as the target.
get_target_attribute¶
Retrieves the attribute of the target to be set by the constraint.
is_attached¶
Checks whether the constraint is attached to a ConstraintLayout,
and it is contributing to the layout.
is_constant¶
Checks whether the constraint describes a relation between an attribute
on the Constraint.target and a constant value.
is_required¶
Checks whether the constraint is a required relation for solving the constraint layout.
Properties¶
constant¶
The constant value to be added to the Constraint.source-attribute.
multiplier¶
The multiplication factor to be applied to
the Constraint.source-attribute.
relation¶
The order relation between the terms of the constraint.
source¶
The source of the constraint.
The constraint will set the Constraint.target-attribute
property of the target using the Constraint.source-attribute
property of the source.
source_attribute¶
The attribute of the Constraint.source read by the
constraint.
strength¶
The strength of the constraint.
The strength can be expressed either using one of the symbolic values
of the ConstraintStrength enumeration, or any positive integer
value.
target¶
The target of the constraint.
The constraint will set the Constraint.target-attribute
property of the target using the Constraint.source-attribute
property of the source widget.
target_attribute¶
The attribute of the Constraint.target set by the constraint.