Clutter.BindConstraint
matches the positional and/or dimensional attributes of the source actor. for fractional positioning, you can use Clutter.AlignConstraint
, but there is no Clutter.Constraint
class that allows you to set a fractional dimensional attribute. you can implement your own ClutterConstraint
that does so by subclassing Clutter.Constraint
and overriding the Clutter.Constraint.do_update_allocation()
virtual function, which gets passed the allocation's of the actor that should be modified by the constraint. something similar to this (untested) code should work:
class MyConstraint (Clutter.Constraint):
def __init__(self, source, width_fraction=1.0, height_fraction=1.0):
Clutter.Constraint.__init__(self)
self._source = source
self._widthf = width_fraction
self._heightf = height_fraction
def do_update_allocation(self, actor, allocation):
source_alloc = self._source.get_allocation()
width = source_alloc.get_width() * self._widthf
height = source_alloc.get_height() * self._heightf
allocation.x2 = allocation.x1 + width
allocation.y2 = allocation.y1 + height
this should illustrate the mechanism used by Clutter.Constraint
to modify the allocation of an actor.