Gtk.ComboBoxText - Classes - Gtk 3.0 (original) (raw)
g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.CellEditable Gtk.CellEditable GObject.GInterface->Gtk.CellEditable Gtk.CellLayout Gtk.CellLayout GObject.GInterface->Gtk.CellLayout GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Bin Gtk.Bin Gtk.ComboBox Gtk.ComboBox Gtk.Bin->Gtk.ComboBox Gtk.Buildable->Gtk.Widget Gtk.CellEditable->Gtk.ComboBox Gtk.CellLayout->Gtk.ComboBox Gtk.ComboBoxText Gtk.ComboBoxText Gtk.ComboBox->Gtk.ComboBoxText Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget->Gtk.Container
Example¶
Subclasses:
None
Methods¶
Inherited:
Gtk.ComboBox (40), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.CellEditable (3), Gtk.CellLayout (9)
Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class | new () |
---|---|
class | new_with_entry () |
append (id, text) | |
append_text (text) | |
get_active_text () | |
insert (position, id, text) | |
insert_text (position, text) | |
prepend (id, text) | |
prepend_text (text) | |
remove (position) | |
remove_all () |
Virtual Methods¶
Inherited:
Gtk.ComboBox (2), Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.CellEditable (3), Gtk.CellLayout (9)
Properties¶
Inherited:
Gtk.ComboBox (16), Gtk.Container (3), Gtk.Widget (39), Gtk.CellEditable (1)
Style Properties¶
Inherited:
Gtk.ComboBox (4), Gtk.Widget (17)
Signals¶
Inherited:
Gtk.ComboBox (5), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Gtk.CellEditable (2)
Fields¶
Inherited:
Gtk.ComboBox (5), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1), Gtk.CellEditable (2)
Name | Type | Access | Description |
---|---|---|---|
parent_instance | Gtk.ComboBox | r |
Class Details¶
class Gtk.ComboBoxText(**kwargs)¶
Bases:
Abstract:
No
Structure:
A Gtk.ComboBoxText is a simple variant of Gtk.ComboBox that hides the model-view complexity for simple text-only use cases.
To create a Gtk.ComboBoxText, use Gtk.ComboBoxText.new() orGtk.ComboBoxText.new_with_entry().
You can add items to a Gtk.ComboBoxText withGtk.ComboBoxText.append_text(), Gtk.ComboBoxText.insert_text() or Gtk.ComboBoxText.prepend_text() and remove options withGtk.ComboBoxText.remove().
If the Gtk.ComboBoxText contains an entry (via the “has-entry” property), its contents can be retrieved using Gtk.ComboBoxText.get_active_text(). The entry itself can be accessed by calling Gtk.Bin.get_child() on the combo box.
You should not call Gtk.ComboBox.set_model() or attempt to pack more cells into this combo box via its Gtk.CellLayout interface.
Gtk.ComboBoxText as Gtk.Buildable
The Gtk.ComboBoxText implementation of the Gtk.Buildable interface supports adding items directly using the <items>
element and specifying <item>
elements for each item. Each <item>
element can specify the “id” corresponding to the appended text and also supports the regular translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying Gtk.ComboBoxText items:
Factory Home SubwayCSS nodes
combobox ╰── box.linked ├── entry.combo ├── button.combo ╰── window.popup
Gtk.ComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.
Returns:
A new Gtk.ComboBoxText
Return type:
Creates a new Gtk.ComboBoxText, which is a Gtk.ComboBox just displaying strings.
New in version 2.24.
classmethod new_with_entry()[source]¶
Returns:
a new Gtk.ComboBoxText
Return type:
Creates a new Gtk.ComboBoxText, which is a Gtk.ComboBox just displaying strings. The combo box created by this function has an entry.
New in version 2.24.
Parameters:
Appends text to the list of strings stored in self. If id is non-None then it is used as the ID of the row.
This is the same as calling Gtk.ComboBoxText.insert() with a position of -1.
New in version 2.24.
Parameters:
text (str) – A string
Appends text to the list of strings stored in self.
This is the same as calling Gtk.ComboBoxText.insert_text() with a position of -1.
New in version 2.24.
Returns:
a newly allocated string containing the currently active text. Must be freed with GLib.free().
Return type:
Returns the currently active string in self, or Noneif none is selected. If self contains an entry, this function will return its contents (which will not necessarily be an item from the list).
New in version 2.24.
insert(position, id, text)[source]¶
Parameters:
- position (int) – An index to insert text
- id (str or None) – a string ID for this value, or None
- text (str) – A string to display
Inserts text at position in the list of strings stored in self. If id is non-None then it is used as the ID of the row. SeeGtk.ComboBox :id-column.
If position is negative then text is appended.
New in version 3.0.
insert_text(position, text)[source]¶
Parameters:
Inserts text at position in the list of strings stored in self.
If position is negative then text is appended.
This is the same as calling Gtk.ComboBoxText.insert() with a NoneID string.
New in version 2.24.
Parameters:
Prepends text to the list of strings stored in self. If id is non-None then it is used as the ID of the row.
This is the same as calling Gtk.ComboBoxText.insert() with a position of 0.
New in version 2.24.
Parameters:
text (str) – A string
Prepends text to the list of strings stored in self.
This is the same as calling Gtk.ComboBoxText.insert_text() with a position of 0.
New in version 2.24.
Parameters:
position (int) – Index of the item to remove
Removes the string at position from self.
New in version 2.24.
Removes all the text entries from the combo box.
New in version 3.0.