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:
from gi.repository import Gtk
from sugar3.graphics.combobox import ComboBox
def __combo_changed_cb(combo):
print 'Combo changed to %r' % combo.get_value()
w = Gtk.Window()
w.connect("destroy", Gtk.main_quit)
combo = ComboBox()
combo.append_item(True, 'one')
combo.append_item(2, 'two', 'go-next')
combo.append_item('3', 'three')
# This will make 'two' active (zero indexed)
combo.set_active(1)
combo.connect('changed', __combo_changed_cb)
w.add(combo)
w.show_all()
Gtk.main()
Bases: gi.overrides.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.
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: |
|
---|
Add a separator to the bottom of the combo box list. The separator can not be selected.
Get the row of data for the currently selected item.
Returns: | row of data in the format:[value, text, pixbuf, is_separator]
|
---|
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 |
---|
Remove all list items from the combo box.
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 |
---|