Previous topic

layout Module

Next topic

list Module

layout_class Module

class efl.elementary.layout_class.LayoutClass

Bases: efl.elementary.object.Object

Elementary, besides having the Layout widget, exposes its foundation – the Elementary Layout Class – in order to create other widgets which are, basically, a certain layout with some more logic on top.

The idea is to make the creation of that widgets as easy as possible, factorizing code on this common base. For example, a button is a layout (that looks like push button) that happens to react on clicks and keyboard events in a special manner, calling its user back on those events. That’s no surprise, then, that the efl.elementary.button.Button implementation relies on LayoutClass, if you go to check it.

Container parts, here, map directly to Edje parts from the layout’s Edje group. Besides that, there’s a whole infrastructure around Edje files:

  • interfacing by signals,
  • setting/retrieving text part values,
  • dealing with table and box parts directly,
  • etc.

Finally, layout objects will do part aliasing for you, if you set it up properly. For that, take a look at Elm_Layout_Part_Alias_Description, where it’s explained in detail.

box_append(unicode part, Object child) → bool

Append child to layout box part.

Once the object is appended, it will become child of the layout. Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. One should use box_remove() to make this layout forget about the object.

Parameters:
  • part (string) – the box part to which the object will be appended.
  • child (Object) – the child object to append to box.
Raises RuntimeError:
 

when adding the child fails

Changed in version 1.8: Raises RuntimeError if adding the child fails

box_insert_at(unicode part, Object child, int pos) → bool

Insert child to layout box part at a given position.

Once the object is inserted, it will become child of the layout. Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. One should use box_remove() to make this layout forget about the object.

Parameters:
  • part (string) – the box part to insert.
  • child (Object) – the child object to insert into box.
  • pos (int) – the numeric position >=0 to insert the child.
Raises RuntimeError:
 

when inserting to box fails

Changed in version 1.8: Raises RuntimeError if adding the child fails

box_insert_before(unicode part, Object child, Object reference) → bool

Insert child to layout box part before a reference object.

Once the object is inserted, it will become child of the layout. Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. One should use box_remove() to make this layout forget about the object.

Parameters:
  • part (string) – the box part to insert.
  • child (Object) – the child object to insert into box.
  • reference (Object) – another reference object to insert before in box.
Raises RuntimeError:
 

when inserting to box fails

Changed in version 1.8: Raises RuntimeError if adding the child fails

box_prepend(unicode part, Object child) → bool

Prepend child to layout box part.

Once the object is prepended, it will become child of the layout. Its lifetime will be bound to the layout, whenever the layout dies the child will be deleted automatically. One should use box_remove() to make this layout forget about the object.

Parameters:
  • part (string) – the box part to prepend.
  • child (Object) – the child object to prepend to box.
Raises RuntimeError:
 

when adding to box fails

Changed in version 1.8: Raises RuntimeError if adding the child fails

box_remove(unicode part, Object child) → evas.Object

Remove a child of the given part box.

The object will be removed from the box part and its lifetime will not be handled by the layout anymore. This is equivalent to part_content_unset() for box.

Parameters:
  • part (string) – The box part name to remove child.
  • child (Object) – The object to remove from box.
Returns:

The object that was being used, or None if not found.

Return type:

Object

box_remove_all(unicode part, bool clear) → bool

Remove all children of the given part box.

The objects will be removed from the box part and their lifetime will not be handled by the layout anymore. This is equivalent to box_remove() for all box children.

Parameters:
  • part (string) – The box part name to remove child.
  • clear (bool) – If True, then all objects will be deleted as well, otherwise they will just be removed and will be dangling on the canvas.
Raises RuntimeError:
 

when removing all items fails

Changed in version 1.8: Raises RuntimeError if removing the children fails

callback_language_changed_add()

the program’s language changed

callback_theme_changed_add()

The theme was changed.

content_get(unicode swallow) → Object

Get the child object in the given content part.

Parameters:swallow (string) – The SWALLOW part to get its content
Returns:The swallowed object or None if none or an error occurred
content_set(unicode swallow, Object content)

Set the layout content.

Once the content object is set, a previously set one will be deleted. If you want to keep that old content object, use the content_unset() function.

Note

In an Edje theme, the part used as a content container is called SWALLOW. This is why the parameter name is called swallow, but it is expected to be a part name just like the second parameter of box_append().

Parameters:
  • swallow (string) – The swallow part name in the edje file
  • content (Object) – The child that will be added in this layout object

Changed in version 1.8: Raises RuntimeError if setting the content fails.

content_unset(unicode swallow)

Unset the layout content.

Unparent and return the content object which was set for this part.

Parameters:swallow (string) – The swallow part name in the edje file
Returns:The content that was being used
Return type:Object
data_get(unicode key) → unicode

Get the edje data from the given layout

This function fetches data specified inside the edje theme of this layout. This function returns None if data is not found.

In EDC this comes from a data block within the group block that it was loaded from. E.g:

collections {
    group {
        name: "a_group";
        data {
           item: "key1" "value1";
           item: "key2" "value2";
        }
    }
}
Parameters:key (string) – The data key
Returns:The edje data string
Return type:string
edje

Get the edje layout

This returns the edje object. It is not expected to be used to then swallow objects via Edje.part_swallow for example. Use part_content_set() instead so child object handling and sizing is done properly.

Note

This function should only be used if you really need to call some low level Edje function on this edje object. All the common stuff (setting text, emitting signals, hooking callbacks to signals, etc.) can be done with proper elementary functions.

Type :Edje
edje_object_can_access

Set accessibility to all texblock(text) parts in the layout object

Makes it possible for all textblock(text) parts in the layout to have accessibility.

Raises RuntimeError:
 if accessibility cannot be set.

New in version 1.8.

end

The end object in a layout that follows the Elementary naming convention for its parts.

Type :Object
file

Set the file path and group of the edje file that will be used as layout.

Type :tuple of string
Raises RuntimeError:
 when setting the file fails

Changed in version 1.8: Raises RuntimeError if setting the file fails

freeze()

Freezes the Elementary layout object.

This function puts all changes on hold. Successive freezes will nest, requiring an equal number of thaws.

Returns:The frozen state or 0 on Error
See :thaw()

New in version 1.8.

icon

The icon object in a layout that follows the Elementary naming convention for its parts.

Type :Object
part_cursor_engine_only_get(unicode part_name) → bool

Gets a specific cursor engine_only for an edje part.

Parameters:part_name (string) – a part from loaded edje group.
Returns:whenever the cursor is just provided by engine or also from theme.
Return type:bool
part_cursor_engine_only_set(unicode part_name, bool engine_only) → bool

Sets if the cursor set should be searched on the theme or should use the provided by the engine, only.

Note

Before you set if should look on theme you should define a cursor with part_cursor_set(). By default it will only look for cursors provided by the engine.

Parameters:
  • part_name (string) – a part from loaded edje group.
  • engine_only (bool) – if cursors should be just provided by the engine (True) or should also search on widget’s theme as well (False)
Returns:

True on success or False on failure, that may be part not exists or it did not had a cursor set.

Return type:

bool

Raises RuntimeError:
 

when setting the engine_only setting fails, when part does not exist or has no cursor set.

Changed in version 1.8: Raises RuntimeError if setting the value fails

part_cursor_get(unicode part_name) → unicode

Get the cursor to be shown when mouse is over an edje part

Parameters:part_name (string) – a part from loaded edje group.
Returns:the cursor name.
Return type:string
part_cursor_set(unicode part_name, unicode cursor) → bool

Sets a specific cursor for an edje part.

Parameters:
  • part_name (string) – a part from loaded edje group.
  • cursor (string) – cursor name to use, see Elementary_Cursor.h
Raises RuntimeError:
 

when setting the parts cursor fails

Changed in version 1.8: Raises RuntimeError if setting the cursor fails

part_cursor_style_get()

part_cursor_get(unicode part_name) -> unicode

Gets a specific cursor style for an edje part.

Parameters:part_name (string) – a part from loaded edje group.
Returns:the theme style in use, defaults to “default”. If the object does not have a cursor set, then None is returned.
Return type:string
part_cursor_style_set(unicode part_name, unicode style) → bool

Sets a specific cursor style for an edje part.

Parameters:
  • part_name (string) – a part from loaded edje group.
  • style (string) – the theme style to use (default, transparent, ...)
Raises RuntimeError:
 

when setting the part cursor style fails

Changed in version 1.8: Raises RuntimeError if setting the cursor style fails

part_cursor_unset(unicode part_name) → bool

Unsets a cursor previously set with part_cursor_set().

Parameters:part_name (string) – a part from loaded edje group, that had a cursor set with part_cursor_set().
Raises RuntimeError:
 when unsetting the part cursor fails

Changed in version 1.8: Raises RuntimeError if unsetting the cursor fails

signal_callback_add()

Add a callback for a (Edje) signal emitted by a layout widget’s underlying Edje object.

This function connects a callback function to a signal emitted by the underlying Edje object. Globs are accepted in either the emission or source strings (see edje_object_signal_callback_add()).

Parameters:
  • emission (string) – The signal’s name string
  • source (string) – The signal’s source string
  • func (function) – The callback function to be executed when the signal is emitted.
signal_callback_del()

Remove a signal-triggered callback from a given layout widget.

This function removes the last callback attached to a signal emitted by the undelying Edje object, with parameters emission, source and func matching exactly those passed to a previous call to signal_callback_add(). The data that was passed to this call will be returned.

Parameters:
  • emission (string) – The signal’s name string
  • source (string) – The signal’s source string
  • func (function) – The callback function being executed when the signal was emitted.
signal_emit(unicode emission, unicode source)

Send a (Edje) signal to a given layout widget’s underlying Edje object.

This function sends a signal to the underlying Edje object. An Edje program on that Edje object’s definition can respond to a signal by specifying matching ‘signal’ and ‘source’ fields.

Parameters:
  • emission (string) – The signal’s name string
  • source (string) – The signal’s source string
sizing_eval()

Eval sizing

Manually forces a sizing re-evaluation. This is useful when the minimum size required by the edje theme of this layout has changed. The change on the minimum size required by the edje theme is not immediately reported to the elementary layout, so one needs to call this function in order to tell the widget (layout) that it needs to reevaluate its own size.

The minimum size of the theme is calculated based on minimum size of parts, the size of elements inside containers like box and table, etc. All of this can change due to state changes, and that’s when this function should be called.

Also note that a standard signal of “size,eval” “elm” emitted from the edje object will cause this to happen too.

table_clear(unicode part, bool clear) → bool

Remove all the child objects of the given part table.

The objects will be removed from the table part and their lifetime will not be handled by the layout anymore. This is equivalent to table_unpack() for all table children.

Parameters:
  • part (string) – The table part name to remove child.
  • clear (bool) – If True, then all objects will be deleted as well, otherwise they will just be removed and will be dangling on the canvas.
Raises RuntimeError:
 

when clearing the table fails

Changed in version 1.8: Raises RuntimeError if clearing the table fails

table_pack(unicode part, Object child_obj, int col, int row, int colspan, int rowspan) → bool

Insert child to layout table part.

Once the object is inserted, it will become child of the table. Its lifetime will be bound to the layout, and whenever the layout dies the child will be deleted automatically. One should use table_unpack() to make this layout forget about the object.

If colspan or rowspan are bigger than 1, that object will occupy more space than a single cell.

Parameters:
  • part (string) – the box part to pack child.
  • child_obj (Object) – the child object to pack into table.
  • col (int) – the column to which the child should be added. (>= 0)
  • row (int) – the row to which the child should be added. (>= 0)
  • colspan (int) – how many columns should be used to store this object. (>= 1)
  • rowspan (int) – how many rows should be used to store this object. (>= 1)
Raises RuntimeError:
 

when packing an item fails

Changed in version 1.8: Raises RuntimeError if adding the child fails

table_unpack(unicode part, Object child_obj) → Object

Unpack (remove) a child of the given part table.

The object will be unpacked from the table part and its lifetime will not be handled by the layout anymore. This is equivalent to part_content_unset() for table.

Parameters:
  • part (string) – The table part name to remove child.
  • child_obj (Object) – The object to remove from table.
Returns:

The object that was being used, or None if not found.

Return type:

Object

text_get(unicode part) → unicode

Get the text set in the given part

Parameters:part (string) – The TEXT part to retrieve the text off
Returns:The text set in part
Return type:string
text_set(unicode part, unicode text)

Set the text of the given part

Parameters:
  • part (string) – The TEXT part where to set the text
  • text (string) – The text to set

Changed in version 1.8: Raises RuntimeError if setting the text fails

thaw()

Thaws the Elementary object.

This function thaws the given Edje object and the Elementary sizing calc.

Returns:The frozen state or 0 if the object is not frozen or on error.

Note

If successive freezes were done, an equal number of thaws will be required.

See :freeze()

New in version 1.8.

theme

Set the edje group class, group name and style from the elementary theme that will be used as layout.

Note that style will be the new style too, as in setting style.

Type :tuple of strings
Raises RuntimeError:
 when setting the theme fails

Changed in version 1.8: Raises RuntimeError if setting the theme fails