Gengrid

../_images/gengrid-preview.png

Widget description

This widget aims to position objects in a grid layout while actually creating and rendering only the visible ones, using the same idea as the Genlist: the user defines a class for each item, specifying functions that will be called at object creation, deletion, etc. When those items are selected by the user, a callback function is issued. Users may interact with a gengrid via the mouse (by clicking on items to select them and clicking on the grid’s viewport and swiping to pan the whole view) or via the keyboard, navigating through item with the arrow keys.

Scrollable Interface

This widget supports the scrollable interface.

If you wish to control the scolling behaviour using these functions, inherit both the widget class and the Scrollable class using multiple inheritance, for example:

class ScrollableGenlist(Genlist, Scrollable):
    def __init__(self, canvas, *args, **kwargs):
        Genlist.__init__(self, canvas)

Gengrid layouts

Gengrid may layout its items in one of two possible layouts:

  • horizontal or

  • vertical.

When in “horizontal mode”, items will be placed in columns, from top to bottom and, when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally, making for horizontal scrolling. When in “vertical mode” , though, items will be placed in rows, from left to right and, when the space for a row is filled, another one is started below, thus expanding the grid vertically (and making for vertical scrolling).

Gengrid items

An item in a gengrid can have 0 or more texts (they can be regular text or textblock Evas objects - that’s up to the style to determine), 0 or more contents (which are simply objects swallowed into the gengrid item’s theming Edje object) and 0 or more boolean states, which have the behavior left to the user to define. The Edje part names for each of these properties will be looked up, in the theme file for the gengrid, under the Edje (string) data items named "texts", "contents" and "states", respectively. For each of those properties, if more than one part is provided, they must have names listed separated by spaces in the data fields. For the default gengrid item theme, we have one text part ("elm.text"), two content parts ("elm.swalllow.icon" and "elm.swallow.end") and no state parts.

A gengrid item may be at one of several styles. Elementary provides one by default - “default”, but this can be extended by system or application custom themes/overlays/extensions (see Theme for more details).

Gengrid item classes

In order to have the ability to add and delete items on the fly, gengrid implements a class (callback) system where the application provides a structure with information about that type of item (gengrid may contain multiple different items with different classes, states and styles). Gengrid will call the functions in this struct (methods) when an item is “realized” (i.e., created dynamically, while the user is scrolling the grid). All objects will simply be deleted when no longer needed with delete(). The GengridItemClass class contains the following attributes and methods:

  • item_style - This is a constant string and simply defines the name of the item style. It must be specified and the default should be default.

  • func.text_get - This function is called when an item object is actually created. The data parameter will point to the same data passed to item_append() and related item creation functions. The obj parameter is the gengrid object itself, while the part one is the name string of one of the existing text parts in the Edje group implementing the item’s theme. See GengridItemClass.text_get().

  • func.content_get - This function is called when an item object is actually created. The data parameter will point to the same data passed to GengridItem.append_to() and related item creation functions. The obj parameter is the gengrid object itself, while the part one is the name string of one of the existing (content) swallow parts in the Edje group implementing the item’s theme. It must return None, when no content is desired, or a valid object handle, otherwise. The object will be deleted by the gengrid on its deletion or when the item is “unrealized”. See GengridItemClass.content_get().

  • func.state_get - This function is called when an item object is actually created. The data parameter will point to the same data passed to GengridItem.append_to() and related item creation functions. The obj parameter is the gengrid object itself, while the part one is the name string of one of the state parts in the Edje group implementing the item’s theme. Return False for false/off or True for true/on. Gengrids will emit a signal to its theming Edje object with "elm,state,xxx,active" and "elm" as “emission” and “source” arguments, respectively, when the state is true (the default is false), where xxx is the name of the (state) part. See GengridItemClass.state_get().

  • func.del - This is called when efl.elementary.object_item.ObjectItem.delete() is called on an item or clear() is called on the gengrid. This is intended for use when gengrid items are deleted, so any data attached to the item (e.g. its data parameter on creation) can be deleted. See GengridItemClass.delete().

Usage hints

If the user wants to have multiple items selected at the same time, multi_select will permit it. If the gengrid is single-selection only (the default), then selected_item will return the selected item or None, if none is selected. If the gengrid is under multi-selection, then selected_items will return a list (that is only valid as long as no items are modified (added, deleted, selected or unselected) of child items on a gengrid.

If an item changes (internal (boolean) state, text or content changes), then use update() to have gengrid update the item with the new state. A gengrid will re-“realize” the item, thus calling the functions in the GengridItemClass set for that item.

To programmatically (un)select an item or get the selected state, use GengridItem.selected. To make an item disabled (unable to be selected and appear differently) or get the disabled state use GengridItem.disabled.

Grid cells will only have their selection smart callbacks called when firstly getting selected. Any further clicks will do nothing, unless you enable the “always select mode”, with select_mode as ELM_OBJECT_SELECT_MODE_ALWAYS, thus making every click to issue selection callbacks. select_mode as ELM_OBJECT_SELECT_MODE_NONE will turn off the ability to select items entirely in the widget and they will neither appear selected nor call the selection smart callbacks.

Remember that you can create new styles and add your own theme augmentation per application with Theme.extension_add. If you absolutely must have a specific style that overrides any theme the user or system sets up you can use Theme.extension_add to add such a file.

Emitted signals

  • activated - The user has double-clicked or pressed (enter|return|spacebar) on an item. The event_info parameter is the gengrid item that was activated.

  • clicked,double - The user has double-clicked an item. The event_info parameter is the gengrid item that was double-clicked.

  • clicked,right - The user has right-clicked an item. The event_info parameter is the item that was right-clicked. (since: 1.13)

  • longpressed - This is called when the item is pressed for a certain amount of time. By default it’s 1 second.

  • selected - The user has made an item selected. The event_info parameter is the gengrid item that was selected.

  • unselected - The user has made an item unselected. The event_info parameter is the gengrid item that was unselected.

  • realized - This is called when the item in the gengrid has its implementing Evas object instantiated, de facto. event_info is the gengrid item that was created.

  • unrealized - This is called when the implementing Evas object for this item is deleted. event_info is the gengrid item that was deleted.

  • changed - Called when an item is added, removed, resized or moved and when the gengrid is resized or gets “horizontal” property changes.

  • scroll,anim,start - This is called when scrolling animation has started.

  • scroll,anim,stop - This is called when scrolling animation has stopped.

  • drag,start,up - Called when the item in the gengrid has been dragged (not scrolled) up.

  • drag,start,down - Called when the item in the gengrid has been dragged (not scrolled) down.

  • drag,start,left - Called when the item in the gengrid has been dragged (not scrolled) left.

  • drag,start,right - Called when the item in the gengrid has been dragged (not scrolled) right.

  • drag,stop - Called when the item in the gengrid has stopped being dragged.

  • drag - Called when the item in the gengrid is being dragged.

  • scroll - called when the content has been scrolled (moved).

  • scroll,drag,start - called when dragging the content has started.

  • scroll,drag,stop - called when dragging the content has stopped.

  • edge,top - This is called when the gengrid is scrolled until the top edge.

  • edge,bottom - This is called when the gengrid is scrolled until the bottom edge.

  • edge,left - This is called when the gengrid is scrolled until the left edge.

  • edge,right - This is called when the gengrid is scrolled until the right edge.

  • moved - This is called when a gengrid item is moved by a user interaction in a reorder mode. The event_info parameter is the item that was moved.

  • index,update - This is called when a gengrid item index is changed. Note that this callback is called while each item is being realized.

  • highlighted - an item in the list is highlighted. This is called when the user presses an item or keyboard selection is done so the item is physically highlighted. The event_info parameter is the item that was highlighted.

  • unhighlighted - an item in the list is unhighlighted. This is called when the user releases an item or keyboard selection is moved so the item is physically unhighlighted. The event_info parameter is the item that was unhighlighted.

  • item,focused - When the gengrid item has received focus. (since 1.10)

  • item,unfocused - When the gengrid item has lost focus. (since 1.10)

  • item,reorder,anim,start - This is called when a gengrid item movement has just started by keys in reorder mode. The parameter is the item that is going to move. (since 1.10)

  • item,reorder,anim,stop - This is called when a gengrid item movement just stopped in reorder mode. The parameter is the item that was moved. (since 1.10)

Enumerations

Items’ scroll to types

efl.elementary.ELM_GENGRID_ITEM_SCROLLTO_NONE

No scroll to

efl.elementary.ELM_GENGRID_ITEM_SCROLLTO_IN

Scroll to the nearest viewport

efl.elementary.ELM_GENGRID_ITEM_SCROLLTO_TOP

Scroll to the top of viewport

efl.elementary.ELM_GENGRID_ITEM_SCROLLTO_MIDDLE

Scroll to the middle of viewport

efl.elementary.ELM_GENGRID_ITEM_SCROLLTO_BOTTOM

Scroll to the bottom of viewport

New in version 1.17.

Multi-select mode

efl.elementary.ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT

Default multiple select mode

New in version 1.10.

efl.elementary.ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL

Disallow mutiple selection when clicked without control key pressed

New in version 1.10.

efl.elementary.ELM_OBJECT_MULTI_SELECT_MODE_MAX

Value unknown

New in version 1.10.

Reorder type

efl.elementary.ELM_GENGRID_REORDER_TYPE_NORMAL

Normal reorder mode

New in version 1.11.

efl.elementary.ELM_GENGRID_REORDER_TYPE_SWAP

Swap reorder mode

New in version 1.11.

Inheritance diagram

Inheritance diagram of Gengrid, GengridItem, GengridItemClass
class efl.elementary.Gengrid(Object parent, *args, **kwargs)

Bases: efl.elementary.__init__.Object

This is the class that actually implements the widget.

Parameters
  • parent (efl.evas.Object) – The parent object

  • **kwargs – All the remaining keyword arguments are interpreted as properties of the instance

align

This sets the alignment of the whole grid of items of a gengrid within its given viewport. By default, those values are both 0.5, meaning that the gengrid will have its items grid placed exactly in the middle of its viewport.

Note

If given alignment values are out of the cited ranges, they’ll be changed to the nearest boundary values on the valid ranges.

Type

tuple of floats

align_get()
align_set(align_x, align_y)
at_xy_item_get(x, y)

Get the item that is at the x, y canvas coords.

Parameters
  • x – The input x coordinate

  • y – The input y coordinate

Returns

(GengridItem, int xposret, int yposret)

This returns the item at the given coordinates (which are canvas relative, not object-relative). If an item is at that coordinate, that item handle is returned, and if xposret is not None, the integer pointed to is set to a value of -1, 0 or 1, depending if the coordinate is on the left portion of that item (-1), on the middle section (0) or on the right part (1). if yposret is not None, the integer pointed to is set to a value of -1, 0 or 1, depending if the coordinate is on the upper portion of that item (-1), on the middle section (0) or on the lower part (1). If None is returned as an item (no item found there), then posret may indicate -1 or 1 based if the coordinate is above or below all items respectively in the gengrid.

New in version 1.8.

bounce

Deprecated since version 1.8: You should combine with Scrollable class instead.

bounce_get()

Deprecated since version 1.8: You should combine with Scrollable class instead.

bounce_set(h, v)

Deprecated since version 1.8: You should combine with Scrollable class instead.

callback_activated_add(func, *args, **kwargs)
callback_activated_del(func)
callback_changed_add(func, *args, **kwargs)

Called when an item is added, removed, resized or moved and when the gengrid is resized or gets “horizontal” property changes.

callback_changed_del(func)
callback_clicked_add(func, *args, **kwargs)
callback_clicked_del(func)
callback_clicked_double_add(func, *args, **kwargs)
callback_clicked_double_del(func)
callback_clicked_right_add(func, *args, **kwargs)

The user has right-clicked an item.

New in version 1.13.

callback_clicked_right_del(func)
callback_drag_add(func, *args, **kwargs)

Called when the item in the gengrid is being dragged.

callback_drag_del(func)
callback_drag_start_down_add(func, *args, **kwargs)

Called when the item in the gengrid has been dragged (not scrolled) down.

callback_drag_start_down_del(func)
callback_drag_start_left_add(func, *args, **kwargs)

Called when the item in the gengrid has been dragged (not scrolled) left.

callback_drag_start_left_del(func)
callback_drag_start_right_add(func, *args, **kwargs)

Called when the item in the gengrid has been dragged (not scrolled) right.

callback_drag_start_right_del(func)
callback_drag_start_up_add(func, *args, **kwargs)

Called when the item in the gengrid has been dragged (not scrolled) up.

callback_drag_start_up_del(func)
callback_drag_stop_add(func, *args, **kwargs)

Called when the item in the gengrid has stopped being dragged.

callback_drag_stop_del(func)
callback_edge_bottom_add(func, *args, **kwargs)

This is called when the gengrid is scrolled until the bottom edge.

callback_edge_bottom_del(func)
callback_edge_left_add(func, *args, **kwargs)

This is called when the gengrid is scrolled until the left edge.

callback_edge_left_del(func)
callback_edge_right_add(func, *args, **kwargs)

This is called when the gengrid is scrolled until the right edge.

callback_edge_right_del(func)
callback_edge_top_add(func, *args, **kwargs)

This is called when the gengrid is scrolled until the top edge.

callback_edge_top_del(func)
callback_highlighted_add(func, *args, **kwargs)

an item in the list is highlighted. This is called when the user presses an item or keyboard selection is done so the item is physically highlighted. The event_info parameter is the item that was highlighted.

callback_highlighted_del(func)
callback_index_update_add(func, *args, **kwargs)

This is called when a gengrid item index is changed. Note that this callback is called while each item is being realized.

callback_index_update_del(func)
callback_item_focused_add(func, *args, **kwargs)

When the gengrid item has received focus.

New in version 1.10.

callback_item_focused_del(func)
callback_item_reorder_anim_start_add(func, *args, **kwargs)

When a gengrid item movement has just started by keys.

New in version 1.10.

callback_item_reorder_anim_start_del(func)
callback_item_reorder_anim_stop_add(func, *args, **kwargs)

When a gengrid item movement just stopped in reorder mode.

New in version 1.10.

callback_item_reorder_anim_stop_del(func)
callback_item_unfocused_add(func, *args, **kwargs)

When the gengrid item has lost focus.

New in version 1.10.

callback_item_unfocused_del(func)
callback_moved_add(func, *args, **kwargs)

This is called when a gengrid item is moved by a user interaction in a reorder mode. The %c event_info parameter is the item that was moved.

callback_moved_del(func)
callback_realized_add(func, *args, **kwargs)

This is called when the item in the gengrid has its implementing Evas object instantiated, de facto. event_info is the gengrid item that was created. The object may be deleted at any time, so it is highly advised to the caller not to use the object returned from GengridItem.object, because it may point to freed objects.

callback_realized_del(func)
callback_scroll_add(func, *args, **kwargs)

called when the content has been scrolled (moved).

callback_scroll_anim_start_add(func, *args, **kwargs)

This is called when scrolling animation has started.

callback_scroll_anim_start_del(func)
callback_scroll_anim_stop_add(func, *args, **kwargs)

This is called when scrolling animation has stopped.

callback_scroll_anim_stop_del(func)
callback_scroll_del(func)
callback_scroll_drag_start_add(func, *args, **kwargs)

called when dragging the content has started.

callback_scroll_drag_start_del(func)
callback_scroll_drag_stop_add(func, *args, **kwargs)

called when dragging the content has stopped.

callback_scroll_drag_stop_del(func)
callback_selected_add(func, *args, **kwargs)
callback_selected_del(func)
callback_unhighlighted_add(func, *args, **kwargs)

an item in the list is unhighlighted. This is called when the user releases an item or keyboard selection is moved so the item is physically unhighlighted. The event_info parameter is the item that was unhighlighted.

callback_unhighlighted_del(func)
callback_unrealized_add(func, *args, **kwargs)

This is called when the implementing Evas object for this item is deleted. event_info is the gengrid item that was deleted.

callback_unrealized_del(func)
callback_unselected_add(func, *args, **kwargs)
callback_unselected_del(func)
clear()

Remove all items from a given gengrid widget.

drag_item_container_add(tm_to_anim, tm_to_drag, itemgetcb=None, data_get=None)

Set a item container (list, genlist, grid) as source of drag

Parameters
  • tm_to_anim – Time period to wait before start animation.

  • tm_to_drag – Time period to wait before start dragging.

  • itemgetcb – Callback to get Evas object for item at (x,y)

  • data_get – Callback to get drag info

Raises

RuntimeError – if setting drag source failed.

New in version 1.17.

drag_item_container_del()

Deletes a item container from drag-source list

Raises

RuntimeError – if deleting drag source failed.

New in version 1.17.

drop_item_container_add(format, itemgetcb=None, entercb=None, enterdata=None, leavecb=None, leavedata=None, poscb=None, posdata=None, dropcb=None, cbdata=None)

Set a item container (list, genlist, grid) as target for drop.

Parameters
  • format – The formats supported for dropping

  • itemgetcb – Callback to get Evas object for item at (x,y)

  • entercb – The function to call when the object is entered with a drag

  • enterdata – The application data to pass to enterdata

  • leavecb – The function to call when the object is left with a drag

  • leavedata – The application data to pass to leavedata

  • poscb – The function to call when the object has a drag over it

  • posdata – The application data to pass to posdata

  • dropcb – The function to call when a drop has occurred

  • cbdata – The application data to pass to dropcb

Raises

RuntimeError – if setting drop target failed.

New in version 1.17.

drop_item_container_del()

Removes a container from list of drop targets.

Raises

RuntimeError – if deleting drop target failed.

New in version 1.17.

filled

The fill state of the whole grid of items of a gengrid within its given viewport. By default, this value is False, meaning that if the first line of items grid’s isn’t filled, the items are centered with the alignment.

Type

bool

filled_get(fill)
filled_set(fill)
first_item

Get the first item in the gengrid widget.

Type

GengridItem

first_item_get()
group_item_size

A gengrid, after creation, has still no information on the size to give to each of its cells. So, you most probably will end up with squares one “finger” wide, the default size. Use this function to force a custom size for you group items, making them as big as you wish.

group_item_size_get()
group_item_size_set(w, h)
highlight_mode

This will turn on/off the highlight effect when items are selected and they will or will not be highlighted. The selected and clicked callback functions will still be called.

Highlight is enabled by default.

highlight_mode_get(fill)
highlight_mode_set(highlight)
horizontal

When in “horizontal mode” (True), items will be placed in columns, from top to bottom and, when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally. When in “vertical mode” (False), though, items will be placed in rows, from left to right and, when the space for a row is filled, another one is started below, thus expanding the grid vertically.

Type

bool

horizontal_get()
horizontal_set(setting)
item_append(item_class, item_data, func=None)

Append a new item (add as last item) to this gengrid.

Parameters
  • item_class – a valid instance that defines the behavior of this item. See GengridItemClass.

  • item_data – some data that defines the model of this item. This value will be given to methods of item_class such as GengridItemClass.text_get(). It will also be provided to func as its last parameter.

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

item_insert_after(item_class, item_data, after_item=None, func=None)

Insert a new item after another item in this gengrid.

Parameters
  • item_class – a valid instance that defines the behavior of this item. See GengridItemClass.

  • item_data – some data that defines the model of this item. This value will be given to methods of item_class such as GengridItemClass.text_get(). It will also be provided to func as its last parameter.

  • after_item – a reference item to use, the new item will be inserted after it.

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

item_insert_before(item_class, item_data, before_item=None, func=None)

Insert a new item before another item in this gengrid.

Parameters
  • item_class – a valid instance that defines the behavior of this item. See GengridItemClass.

  • item_data – some data that defines the model of this item. This value will be given to methods of item_class such as GengridItemClass.text_get(). It will also be provided to func as its last parameter.

  • before_item – a reference item to use, the new item will be inserted before it.

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

item_prepend(item_class, item_data, func=None)

Prepend a new item (add as first item) to this gengrid.

Parameters
  • item_class – a valid instance that defines the behavior of this item. See GengridItemClass.

  • item_data – some data that defines the model of this item. This value will be given to methods of item_class such as GengridItemClass.text_get(). It will also be provided to func as its last parameter.

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

item_size

A gengrid, after creation, has still no information on the size to give to each of its cells. So, you most probably will end up with squares one finger wide, the default size. Use this property to force a custom size for you items, making them as big as you wish.

item_size_get()
item_size_set(w, h)
items_count

Return how many items are currently in a list.

Type

int

last_item

Get the last item in the gengrid widget.

Type

GengridItem

last_item_get()
multi_select

Multi-selection is the ability to have more than one item selected, on a given gengrid, simultaneously. When it is enabled, a sequence of clicks on different items will make them all selected, progressively. A click on an already selected item will unselect it. If interacting via the keyboard, multi-selection is enabled while holding the “Shift” key.

Note

By default, multi-selection is disabled on gengrids.

Type

bool

multi_select_get()
multi_select_mode

Gengrid multi select mode.

  • ELM_OBJECT_MULTI_SELECT_MODE_DEFAULT : select/unselect items whenever each item is clicked.

  • ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL : Only one item will be selected although multi-selection is enabled, if clicked without pressing control key. This mode is only available with multi-selection.

(If getting mode is failed, it returns ELM_OBJECT_MULTI_SELECT_MODE_MAX)

See

multi_select

Type

Multi-select mode

New in version 1.10.

multi_select_set(multi)
nth_item_get(nth)

Get the nth item, in a given gengrid widget, placed at position nth, in its internal items list

Parameters

nth – The number of the item to grab (0 being the first)

Returns

The item stored in the object at position nth or None, if there’s no item with that index (and on errors)

New in version 1.8.

page_relative

Gengrid widget’s scrolling page size, relative to its viewport size.

Type

(float h_pagerel, float v_pagerel)

New in version 1.10.

page_size

Set a given gengrid widget’s scrolling page size

Type

(int h_pagesize, int v_pagesize)

New in version 1.10.

realized_items

This returns a tuple of the realized items in the gengrid.

Type

tuple of GengridItem

realized_items_get()
realized_items_update()

This updates all realized items by calling all the item class functions again to get the contents, texts and states. Use this when the original item data has changed and the changes are desired to be reflected.

To update just one item, use GengridItem.update()

reorder_mode

If a gengrid is set to allow reordering, a click held for more than 0.5 over a given item will highlight it specially, signaling the gengrid has entered the reordering state. From that time on, the user will be able to, while still holding the mouse button down, move the item freely in the gengrid’s viewport, replacing to said item to the locations it goes to. The replacements will be animated and, whenever the user releases the mouse button, the item being replaced gets a new definitive place in the grid.

Type

bool

reorder_mode_get(mode)
reorder_mode_set(mode)
reorder_mode_start(tween_mode)

Enable the gengrid widget mode reordered with keys.

Parameters

tween_mode (efl.ecore.Ecore_Pos_Map) – Position mappings for animation

New in version 1.10.

reorder_mode_stop()

Stop the gengrid widget mode reorder.

New in version 1.10.

reorder_type

Set the order type.

This affect the way items are moved (when in reorder mode) with the keyboard arrows.

Type

Reorder type

New in version 1.11.

reorder_type_set(value)
scroller_policy

Deprecated since version 1.8: You should combine with Scrollable class instead.

scroller_policy_get()

Deprecated since version 1.8: You should combine with Scrollable class instead.

scroller_policy_set(policy_h, policy_v)

Deprecated since version 1.8: You should combine with Scrollable class instead.

search_by_text_item_get(item_to_search_from, part_name, pattern, flags)

Search gengrid item by given string.

This function uses globs (like “*.jpg”) for searching and takes search flags as last parameter. That is a bitfield with values to be ored together or 0 for no flags.

Parameters
  • item_to_search_from (GengridItem) – item to start search from, or None to search from the first item.

  • part_name (string) – Name of the TEXT part of gengrid item to search string in (usually “elm.text”).

  • pattern (string) – The search pattern.

  • flags (Glob matching) – Search flags

Returns

The first item found

Return type

GengridItem

New in version 1.11.

select_mode

Item select mode in the gengrid widget. Possible values are:

  • ELM_OBJECT_SELECT_MODE_DEFAULTItems will only call their

    selection func and callback when first becoming selected. Any further clicks will do nothing, unless you set always select mode.

  • ELM_OBJECT_SELECT_MODE_ALWAYSThis means that, even if selected,

    every click will make the selected callbacks be called.

  • ELM_OBJECT_SELECT_MODE_NONEThis will turn off the ability to

    select items entirely and they will neither appear selected nor call selected callback functions.

select_mode_get()
select_mode_set(mode)
selected_item

This returns the selected item. If multi selection is enabled (multi_select), only the first item in the list is selected, which might not be very useful. For that case, see selected_items.

Type

GengridItem

selected_item_get()
selected_items

This returns a tuple of the selected items, in the order that they appear in the grid.

See also

selected_item

Type

tuple of GengridItem

selected_items_get()
wheel_disabled

Enable or disable mouse wheel to be used to scroll the gengrid.

Mouse wheel can be used for the user to scroll up and down the gengrid.

It’s enabled by default.

Type

bool

New in version 1.10.

class efl.elementary.GengridItem(GengridItemClass item_class, item_data=None, func=None, func_data=None, *args, **kwargs)

Bases: efl.elementary.__init__.ObjectItem

An item for the Gengrid widget.

Parameters
  • item_class – a valid instance that defines the behavior of this item. See GengridItemClass.

  • item_data – some data that defines the model of this item. This value will be given to methods of item_class such as GengridItemClass.text_get(). It will also be provided to func as its last parameter.

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

all_contents_unset()

Unset all contents fetched by the item class

This instructs gengrid to release references to contents in the item, meaning that they will no longer be managed by gengrid and are floating “orphans” that can be re-used elsewhere.

Returns

The list of now orphans objects

Return type

list

New in version 1.18.

Warning

Don’t forget to do something with the returned objects, they are hidden in the canvas, but still alive. You should at least delete them if you don’t need to reuse.

append_to(gengrid)

Append a new item (add as last item) to this gengrid.

New in version 1.8.

bring_in(scrollto_type=enums.ELM_GENGRID_ITEM_SCROLLTO_IN)

This causes gengrid to jump to the item and show it (by scrolling), if it is not fully visible. This will use animation to do so and take a period of time to complete.

See also

show()

Parameters

scrollto_type (Items’ scroll to types) – Where to position the item in the viewport.

custom_size

Custom size mode for non-homogeneous gengrid.

In case of a horizontal grid, only the widths will be resized and in case of vertical only the heights can be resized. Item size should be set by elm_gengrid_item_size_set() beforehand.

Type

(int w, int h)

New in version 1.19.

custom_size_get()
custom_size_set(w, h)
data

User data for the item.

data_get()
index

Get the index of the item. It is only valid once displayed.

index_get()
insert_after(after)

Insert a new item after another item in this gengrid.

Parameters

after – a reference item to use, the new item will be inserted after it.

New in version 1.8.

insert_before(before)

Insert a new item before another item in this gengrid.

Parameters

before – a reference item to use, the new item will be inserted before it.

New in version 1.8.

next

This returns the item placed after the item, on the container gengrid.

next_get()
pos_get()
prepend_to(gengrid)

Prepend a new item (add as first item) to this gengrid.

New in version 1.8.

prev

This returns the item placed before the item, on the container gengrid.

prev_get()
select_mode

Item’s select mode. Possible values are:

Type

Selection modes

select_mode_get()
select_mode_set(mode)
selected

The selected state of an item. If multi-selection is not enabled on the containing gengrid and selected is True, any other previously selected items will get unselected in favor of a new one.

selected_get()
selected_set(selected)
show(scrollto_type=enums.ELM_GENGRID_ITEM_SCROLLTO_IN)

This causes gengrid to redraw its viewport’s contents to the region containing the given item, if it is not fully visible.

See also

bring_in()

Parameters

scrollto_type (Items’ scroll to types) – Where to position the item in the viewport.

sorted_insert(gengrid, compare_func)

Insert a new item after another item in this gengrid.

Parameters

after – a reference item to use, the new item will be inserted after it.

New in version 1.8.

update()

This updates an item by calling all the item class functions again to get the contents, texts and states. Use this when the original item data has changed and you want the changes to be reflected.

class efl.elementary.GengridItemClass(item_style=None, text_get_func=None, content_get_func=None, state_get_func=None, del_func=None)

Bases: object

Defines the behavior of each grid item.

This class should be created and handled to the Gengrid itself.

It may be subclassed, in this case the methods text_get(), content_get(), state_get() and delete() will be used.

It may also be instantiated directly, given getters to override as constructor parameters.

Parameters
  • item_style – the string that defines the gengrid item theme to be used. The corresponding edje group will have this as suffix.

  • text_get_func – if provided will override the behavior defined by text_get() in this class. Its purpose is to return the label string to be used by a given part and row. This function should have the signature: func(obj, part, item_data) -> str

  • content_get_func – if provided will override the behavior defined by content_get() in this class. Its purpose is to return the icon object to be used (swallowed) by a given part and row. This function should have the signature: func(obj, part, item_data) -> obj

  • state_get_func – if provided will override the behavior defined by state_get() in this class. Its purpose is to return the boolean state to be used by a given part and row. This function should have the signature: func(obj, part, item_data) -> bool

  • del_func – if provided will override the behavior defined by delete() in this class. Its purpose is to be called when item is deleted, thus finalizing resources and similar. This function should have the signature: func(obj, item_data)

Note

In all these signatures, ‘obj’ means Gengrid and ‘item_data’ is the value given to Gengrid item append/prepend methods, it should represent your item model as you want.

content_get(obj, part, item_data)

To be called by Gengrid for each item to get its icon.

Parameters
  • obj – the Gengrid instance

  • part – the part that is being handled.

  • item_data – the value given to gengrid append/prepend.

Returns

icon object to be used and swallowed.

Return type

evas Object or None

free()

Free the C level struct.

New in version 1.8.

item_style

The style of this item class.

ref()

Increase the C level reference count.

New in version 1.8.

state_get(obj, part, item_data)

To be called by Gengrid for each item to get its state.

Parameters
  • obj – the Gengrid instance

  • part – the part that is being handled.

  • item_data – the value given to gengrid append/prepend.

Returns

boolean state to be used.

Return type

bool or None

text_get(obj, part, item_data)

To be called by Gengrid for each item to get its label.

Parameters
  • obj – the Gengrid instance

  • part – the part that is being handled.

  • item_data – the value given to gengrid append/prepend.

Returns

label to be used.

Return type

str or None

unref()

Decrease the C level reference count.

New in version 1.8.