sugar4.graphics.combobox

The combobox module provides a combo box; a button like widget which creates a list popup when clicked. It’s best used outside of a toolbar when the user needs to choose from a short list of items.

Example:

Classes

ComboBox

This class provides a simple wrapper based on the Gtk.ComboBox.

Module Contents

class sugar4.graphics.combobox.ComboBox[source]

Bases: gi.repository.Gtk.ComboBox

This class provides a simple wrapper based on the Gtk.ComboBox. This lets you make a list of items, with a value, label and optionally an icon.

__gtype_name__ = 'SugarComboBox'[source]
get_value()[source]

The value of the currently selected item; the same as the value argument that was passed to the append_item func.

Returns:

object, value of selected item

value[source]
append_item(value, text, icon_name=None, file_name=None)[source]

This function adds another item to the bottom of the combo box list.

If either icon_name or file_name are supplied and icon column will be added to the combo box list.

Parameters:
  • value (object) – the value that will be returned by get_value, when this item is selected

  • text (str) – the user visible label for the item

  • icon_name (str) – the name of the icon in the theme to use for this item, optional and conflicting with file_name

  • file_name (str) – the path to a sugar (svg) icon to use for this item, optional and conflicting with icon_name

append_separator()[source]

Add a separator to the bottom of the combo box list. The separator can not be selected.

get_active_item()[source]

Get the row of data for the currently selected item.

Returns:

row of data in the format:

[value, text, pixbuf, is_separator]

remove_all()[source]

Remove all list items from the combo box.