From 7db59a7cabf52180e122e777fa82ebff0958df66 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 31 May 2005 18:40:17 +0000 Subject: [PATCH] * src/AutoComp.py (StandardCustomSelector): Add autocompletion. svn: r4745 --- gramps2/ChangeLog | 2 ++ gramps2/src/AutoComp.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 06e272622..62a625e62 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -4,6 +4,8 @@ * src/RelLib.py (Witness): Remove class, as it is obsoleted by the EventRef class. + * src/AutoComp.py (StandardCustomSelector): Add autocompletion. + 2005-05-30 Alex Roitman * src/RelLib.py: Move constants back to RelLib, as class attributes. * src/Utils.py: Move constant mappings from const.py.in. diff --git a/gramps2/src/AutoComp.py b/gramps2/src/AutoComp.py index 5524ab5bd..3b0295c55 100644 --- a/gramps2/src/AutoComp.py +++ b/gramps2/src/AutoComp.py @@ -104,19 +104,31 @@ class StandardCustomSelector: @param active_key: The key for the entry to make active upon creation @type active_key: int """ + + # set variables self.mapping = mapping self.custom_key = custom_key self.active_key = active_key self.active_index = 0 + # make model self.store = gtk.ListStore(gobject.TYPE_INT,gobject.TYPE_STRING) + # fill it up using mapping self.fill() + # create combo box entry self.selector = gtk.ComboBoxEntry(self.store,1) if self.active_key: self.selector.set_active(self.active_index) + # make autocompletion work + completion = gtk.EntryCompletion() + completion.set_model(self.store) + completion.set_minimum_key_length(1) + completion.set_text_column(1) + self.selector.child.set_completion(completion) + def fill(self): keys = self.mapping.keys() keys.sort(self.by_value) @@ -163,7 +175,7 @@ if __name__ == "__main__": gtk.main_quit() - s = StandardCustomSelector({0:'a',1:'b',2:'c'},0) + s = StandardCustomSelector({0:'abc',1:'abd',2:'bbe'},0) w = gtk.Dialog() w.child.add(s.selector) w.connect('delete-event',here)