Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making a todo like application with indicator support using glade/python/pygtk/glade. I am making a form to save a Todo item. Each todo will belong to 0 or more projects.

When a user enters a project name in a text input field I want it to auto-complete based on existing projects. This widget should behave similarly to the text input when completing the ask a question form on this site ( Below is a screenshot of what I mean.

For example when the user wants to add a todo under the projects "quickly" once the user starts typing "qu*" it should suggest all available projects that start with "qu" (e.g. "quick", "quickly", "queue", "quack" etc.). The user may press the down arrow to select the correct option or continue typing. When the user presses spacebar, it should start with a new suggestion.

Is there a control/widget in pyGTK/quickly that I can use to accomplish this? Bonus points if I can also list a number next to each suggestion with the number of todo items that belong to this project, similar to the screenshot below.

Auto-completion on

share|improve this question
up vote 3 down vote accepted

Here's a simple example:

from gi.repository import Gtk

class MyExample(Gtk.Window):
    def __init__(self):
        self.connect("delete-event", Gtk.main_quit)

        liststore = Gtk.ListStore(str)
        for match in ["test1", "test2", "test3", "spam", "foo", "eggs", "bar"]:

        completion = Gtk.EntryCompletion()

        entry = Gtk.Entry()

if __name__ == "__main__":
    app = MyExample()

You'll just have to dynamicly fill the liststore with the values you want. Displaying a number next to it can be as trivial as appending it to the string you're adding to the liststore or you can create a second column in it. This all depends on your code and isn't possible to answer, but this should get you going.

You can even create most of the above code in Glade if you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.