Segment Control

../_images/segmentcontrol-preview.png

Widget description

Segment control widget is a horizontal control made of multiple segment items, each segment item functioning similar to discrete two state button. A segment control groups the items together and provides compact single button with multiple equal size segments.

Segment item size is determined by base widget size and the number of items added. Only one segment item can be at selected state. A segment item can display combination of Text and any Evas_Object like Images or other widget.

Emitted signals

  • changed - When the user clicks on a segment item which is not previously selected and get selected. The event_info parameter is the segment item.

Layout content parts

  • icon - An icon in a segment control item

Layout text parts

  • default - Title label in a segment control item

Inheritance diagram

Inheritance diagram of SegmentControl
class efl.elementary.SegmentControl(Object parent, *args, **kwargs)

Bases: efl.elementary.__init__.LayoutClass

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

callback_changed_add(func, *args, **kwargs)

When the user clicks on a segment item which is not previously selected and get selected. The event_info parameter is the segment item.

callback_changed_del(func)
item_add(icon=None, label=None)

Append a new item to the segment control object.

A new item will be created and appended to the segment control, i.e., will be set as last item.

If it should be inserted at another position, item_insert_at() should be used instead.

Items created with this function can be deleted with function efl.elementary.object_item.ObjectItem.delete() or item_del_at().

Simple example:

sc = SegmentControl(win)
ic = Icon(win, file="path/to/image", resizable=(True, True))
sc.item_add(ic, "label")
sc.show()

Note

label set to None is different from empty string “”. If an item only has icon, it will be displayed bigger and centered. If it has icon and label, even that an empty string, icon will be smaller and positioned at left.

Parameters
  • icon (Object) – The icon object to use for the left side of the item. An icon can be any Evas object, but usually it is an Icon.

  • label (string) – The label of the item. Note that, None is different from empty string “”.

Returns

The created item or None upon failure.

Return type

SegmentControlItem

item_count

Get the Segment items count from segment control.

It will just return the number of items added to the segment control.

Type

int

item_del_at(index)

Remove a segment control item at given index from its parent, deleting it.

Items can be added with item_add() or item_insert_at().

Parameters

index (int) – The position of the segment control item to be deleted.

item_get(index)

Get the item placed at specified index.

Index is the position of an item in segment control widget. Its range is from 0 to <tt> count - 1 </tt>. Count is the number of items, that can be get with item_count.

Parameters

index (int) – The index of the segment item.

Returns

The segment control item or None on failure.

Return type

SegmentControlItem

item_icon_get(index)

Get the icon associated to the item.

The return value is the icon associated to the item when it was created, with function item_add(), or later with function part_content_set(). If no icon was passed as argument, it will return None.

Parameters

index (int) – The index of the segment item.

Returns

The left side icon associated to the item at index.

Return type

Object

item_insert_at(icon=None, label=None, index=0)

Insert a new item to the segment control object at specified position.

Index values must be between 0, when item will be prepended to segment control, and items count, that can be get with item_count, case when item will be appended to segment control, just like item_add().

Items created with this function can be deleted with function delete() or item_del_at().

Note

label set to None is different from empty string “”. If an item only has icon, it will be displayed bigger and centered. If it has icon and label, even that an empty string, icon will be smaller and positioned at left.

See also

item_add() item_count efl.elementary.object_item.ObjectItem.delete()

Parameters
  • icon (Object) – The icon object to use for the left side of the item. An icon can be any Evas object, but usually it is an Icon.

  • label (string) – The label of the item.

  • index (int) – Item position. Value should be between 0 and items count.

Returns

The created item or None upon failure.

Return type

SegmentControlItem

item_label_get(index)

Get the label of item.

The return value is the label associated to the item when it was created, with function item_add(), or later with function text. If no label was passed as argument, it will return None.

Parameters

index (int) – The index of the segment item.

Returns

The label of the item at index.

Return type

string

item_selected

The selected item.

The selected item always will be highlighted on segment control.

Type

SegmentControlItem

class efl.elementary.SegmentControlItem(Object icon=None, label=None, *args, **kwargs)

Bases: efl.elementary.__init__.ObjectItem

An item for SegmentControl.

add_to(sc)

Append a new item to the segment control object.

A new item will be created and appended to the segment control, i.e., will be set as last item.

If it should be inserted at another position, item_insert_at() should be used instead.

Items created with this function can be deleted with function efl.elementary.object_item.ObjectItem.delete() or item_del_at().

Simple example:

sc = SegmentControl(win)
ic = Icon(win)
ic.file_set("path/to/image")
ic.resizable_set(True, True)
sc.item_add(ic, "label")
sc.show()

Note

label set to None is different from empty string “”. If an item only has icon, it will be displayed bigger and centered. If it has icon and label, even that an empty string, icon will be smaller and positioned at left.

Parameters
  • icon (Object) – The icon object to use for the left side of the item. An icon can be any Evas object, but usually it is an Icon.

  • label (string) – The label of the item. Note that, None is different from empty string “”.

Returns

The created item or None upon failure.

Return type

SegmentControlItem

index

Get the index of an item.

Index is the position of an item in segment control widget. Its range is from 0 to <tt> count - 1 </tt>. Count is the number of items, that can be get with elm_segment_control_item_count_get().

Type

int

item_insert_at(sc, index=0)

Insert a new item to the segment control object at specified position.

Index values must be between 0, when item will be prepended to segment control, and items count, that can be get with item_count, case when item will be appended to segment control, just like item_add().

Items created with this function can be deleted with function delete() or item_del_at().

Note

label set to None is different from empty string “”. If an item only has icon, it will be displayed bigger and centered. If it has icon and label, even that an empty string, icon will be smaller and positioned at left.

See also

item_add() item_count efl.elementary.object_item.ObjectItem.delete()

Parameters
  • icon (Object) – The icon object to use for the left side of the item. An icon can be any Evas object, but usually it is an Icon.

  • label (string) – The label of the item.

  • index (int) – Item position. Value should be between 0 and items count.

Returns

The created item or None upon failure.

Return type

SegmentControlItem

object

Get the base object of the item.

Type

SegmentControl

selected

Set the selected state of an item.

This sets the selected state of the given item it. True for selected, False for not selected.

If a new item is selected the previously selected will be unselected.

The selected item always will be highlighted on segment control.

Type

bool