Saturday, February 10, 2007

Setting the active text on a ComboBox

I had some trouble finding this on the Interweb, so here's how you set the active text on a ComboBox:

def set_combo_value(self, combo, value):
model=combo.get_model()
for item in model:
if item[0]==value:
combo.set_active_iter(item.iter)
break

Setting the active item by index you can get right off the ComboBox API.

No comments: