Search code examples
pythongtkgtk2

How to change "style property" in pygtk2


GTK ComboBox has style property "arrow-size" (link). I want to set it to 0.

Unfortunately next snippet doesn't work. No error messages reported and arrow appears in default size (=15)

import pygtk
pygtk.require('2.0')
import gtk


def the_dialog():
    dialog = gtk.Dialog("Title", None, gtk.DIALOG_MODAL)
    liststore = gtk.ListStore(str)

    for a in ["one","two","three"]:
        liststore.append([a])

    rc_str = """
   style 'no_arrow_style' {
       GtkComboBox::arrow-size = 0
   }
   widget_class '*' style 'no_arrow_style'
   """
    gtk.rc_parse_string(rc_str)

    combo_box = gtk.ComboBox()
    cell = gtk.CellRendererText()
    combo_box.pack_start(cell)
    combo_box.add_attribute(cell, 'text', 0)
    combo_box.set_model(liststore)
    combo_box.get_cells()

    dialog.vbox.pack_start(combo_box)
    dialog.show_all()

    dialog.run()


the_dialog()

Combo box with default "v"-shaped arrow:

Combo box with default "v"-shaped arrow


Solution

  • GtkComboBox::arrow-size actually means "minimum arrow size". To see the difference set it to 100. The example snippet did work.