Search code examples
gtkpygtkgtk3gtk#gtkmm

How to create a Gtk combobox with the interface new_with_area?


According to the gtk documentation you can create a combobox with:

GtkWidget * gtk_combo_box_new ()
GtkWidget * gtk_combo_box_new_with_entry ()
GtkWidget * gtk_combo_box_new_with_model ()
GtkWidget * gtk_combo_box_new_with_model_and_entry ()
GtkWidget * gtk_combo_box_new_with_area ()
GtkWidget * gtk_combo_box_new_with_area_and_entry ()

I have found a lot of examples for the gtk_combo_box_new_with_model but I can't find anything related to the use of gtk_combo_box_new_with_area .

The langage used doesn't matter.


Solution

  • something like (pygobject):

    from gi.repository import Gtk
    area = Gtk.CellAreaBox()
    combo = Gtk.ComboBox.new_with_area(area=area)
    cell = Gtk.CellRendererText()
    area.pack_start(cell, True, True, True)
    

    you can add more CellRenderers to the box (which is a Gtk.Box) and do whatever you need to do with those.