diff --git a/src/gui/widgets/shortlistcomboentry.py b/src/gui/widgets/shortlistcomboentry.py index a1681c823..ce435c8c6 100644 --- a/src/gui/widgets/shortlistcomboentry.py +++ b/src/gui/widgets/shortlistcomboentry.py @@ -82,11 +82,19 @@ class ShortlistComboEntry(ValidatedComboEntry): # create the model and insert the items model = gtk.ListStore(gtype, gobject.TYPE_BOOLEAN) + maxlen = -1 for item in items: + if len(str(item)) > maxlen: + maxlen = len(str(item)) model.append((item, False)) - + + width = -1 #default width + if 1 < maxlen < 4: + width = 4 + elif 1 < maxlen < 10: + width = maxlen + 1 ValidatedComboEntry.__init__(self, data_type, model, - COLUMN_ITEM, validator) + COLUMN_ITEM, validator, width=width) if shortlist: self._shortlist = [] self.connect("changed", self._on_combobox_changed) diff --git a/src/gui/widgets/validatedcomboentry.py b/src/gui/widgets/validatedcomboentry.py index 97fcaec0e..7ff5cad6b 100644 --- a/src/gui/widgets/validatedcomboentry.py +++ b/src/gui/widgets/validatedcomboentry.py @@ -65,10 +65,11 @@ class ValidatedComboEntry(gtk.ComboBox, gtk.CellLayout): """ __gtype_name__ = "ValidatedComboEntry" - def __init__(self, datatype, model=None, column=-1, validator=None): + def __init__(self, datatype, model=None, column=-1, validator=None, width=-1): gtk.ComboBox.__init__(self, model) self._entry = gtk.Entry() + self._entry.set_width_chars(width) # dummy_event = gtk.gdk.Event(gtk.gdk.NOTHING)