efl.evas.Smart Class

class efl.evas.Smart

Bases: object

An abstract class that defines the behavior of the SmartObject.


clipped (bool) – Make this Smart use a clipped class, ignoring the provided callback methods, except calculate() and resize().

New in version 1.14.

static delete(obj)

Called in order to remove object from canvas and deallocate its resources.

Usually you delete object’s children here.

static member_add(obj, Object child)

Called when children is added to object.

static member_del(obj, Object child)

Called when children is removed from object.

static move(obj, int x, int y)

Called in order to move object to given position.

Usually you move children here.

static resize(obj, int w, int h)

Called in order to resize object.

static show(obj)

Called in order to show the given element.

Usually you call the same function on children.

static hide(obj)

Called in order to hide the given element.

Usually you call the same function on children.

static color_set(obj, int r, int g, int b, int a)

Called in order to change object color.

static clip_set(obj, Eo clip)

Called in order to limit object’s visible area.

static clip_unset(obj)

Called in order to unlimit object’s visible area.

static calculate(obj)

Called before object is used for rendering and it is marked as dirty/changed with changed().


efl.evas.SmartObject Class

class efl.evas.SmartObject(Canvas canvas, Smart smart, **kwargs)

Bases: efl.evas.Object

Smart Evas Objects.

Smart objects are user-defined Evas components, often used to group multiple basic elements, associate an object with a clip and deal with them as an unit. See evas documentation for more details.

Pay attention that just creating an object within the SmartObject doesn’t make it a member! You must do member_add() or use one of the provided factories to ensure that. Failing to do so will leave created objects on different layer and no stacking will be done for you.


If you redefine object’s __init__(), you MUST call your parent! Failing to do so will result in objects that just work from Python and not from C, for instance, adding your object to Edje swallow that clips or set color it will not behave as expected.

  • canvas (Canvas) – Evas canvas for this object

  • smart (Smart) – Smart prototype

Changed in version 1.14: API was broken because this class had some “hackish” behavior which could no longer be supported because of changes in Cython 0.21.1

The abstract methods are now in a separate class Smart which should be instantiated and passed to this classes constructor as parameter smart

callback_add(name, func, *args, **kargs)

Add a callback for the smart event specified by event.

  • name – Event name

  • func

    What to callback. Should have the signature:

    function(object, event_info, *args, **kargs)


TypeError – if func is not callable.


event_info will always be a python object, if the signal is provided by a C-only class, it will crash.

callback_call(name, event_info=None)

Call any smart callbacks for event.

  • name – the event name

  • event_info – an event specific info to pass to the callback.

This should be called internally in the smart object when some specific event has occurred. The documentation for the smart object should include a list of possible events and what type of event_info to expect.


event_info will always be a python object.

callback_del(name, func)

Remove a smart callback.

Removes a callback that was added by callback_add().

  • name – event name

  • func – what to callback, should have be previously registered.


event and func must be used as parameter for callback_add().


ValueError – if there was no func connected with this event.

callback_description_find(name, search_class=True, search_instance=True)

Find callback description for callback given in name.

or None if not found.

  • name (string) – name of desired callback, must not be None.

  • search_class (bool) – whether to search in class descriptions

  • search_instance (bool) – whether to search in instance descriptions


reference to description if found, None if not found.

callback_descriptions_get(get_class=True, get_instance=True)

Retrieve a smart object’s known smart callback descriptions

This call searches for registered callback descriptions for both instance and class of the given smart object. These lists will be sorted by name.


If just class descriptions are of interest, try Smart.callbacks_descriptions_get() instead.

  • get_class (bool) – Get class descriptions

  • get_instance (bool) – Get instance descriptions


A tuple with two lists, for both class and instance descriptions.

Return type



Set an smart object instance’s smart callbacks descriptions.


True on success, False on failure.

These descriptions are hints to be used by introspection and are not enforced in any way.

It will not be checked if instance callbacks descriptions have the same name as respective possibly registered in the smart object class. Both are kept in different arrays and users of callbacks_descriptions_get() should handle this case as they wish.


While instance callbacks descriptions are possible, they are not recommended. Use class callbacks descriptions instead as they make you smart object user’s life simpler and will use less memory, as descriptions and arrays will be shared among all instances.


descriptions – A list with SmartCbDescription descriptions. List elements won’t be modified at run time, but references to them and their contents will be made, so this array should be kept alive during the whole object’s lifetime.


Mark object as changed, so it’s calculate() will be called.

If an object is changed and it provides a calculate() method, it will be called from Canvas.render(), what we call pre-render calculate.

This can be used to postpone heavy calculations until you need to display the object, example: layout calculations.


Set an evas object as a member of this object.

Members will automatically be stacked and layered with the smart object. The various stacking function will operate on members relative to the other members instead of the entire canvas.

Non-member objects can not interleave a smart object’s members.


if child is already member of another SmartObject, it will be deleted from that membership and added to this object.

static member_del(child)

Removes a member object from a smart object.


this will actually map to C API as evas_object_smart_member_del(child), so the object will loose it’s parent event if the object is not part of this object.

Return type

tuple of Object

move_children_relative(dx, dy)

Moves all children objects relative to a given offset.

This will make each of object’s children to move, from where they before, with those delta values (offsets) on both directions.


This is most useful on custom Smart.move() functions.


Clipped smart objects already make use of this function on their Smart.move() function definition.

  • dx – horizontal offset (delta).

  • dy – vertical offset (delta).


The need_recalculate flag of given smart object.

If this flag is set then calculate() callback (method) of the given smart object will be called, if one is provided, during render phase usually evas_render(). After this step, this flag will be automatically unset.

If no calculate() is provided, this flag will be left unchanged.


Just setting this flag will not make scene dirty and evas_render() will have no effect. To do that, use evas_object_smart_changed(), that will automatically call this function with 1 as parameter.


This flag will be unset during the render phase, after calculate() is called if one is provided. If no calculate() is provided, then the flag will be left unchanged after render phase.